note 7855 modified in pg_exec by ronabop

From: Date: Thu, 17 Aug 2000 09:12:53 +0000
Subject: note 7855 modified in pg_exec by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-2093@lists.php.net to get a copy of this message
On pg_getlastoid vs. SELECT currval('some_table_seq'); One or the other may work better, depending on usage. Currval() has a concurrency problem, however. If two users hit a page at close to the same time, _before_ an insert (say, 2-10 milliseconds of eachother), they will both get the same currval... the PHP code may do an increment for you, and then an insert.. This means that they will both try to use the next number for their serial number. There is a similar issue with nextval(). If two users get one at similar times, but one abandons the session/pageload/whatever, you can wind up with holes in the serial numbers. Hence, pg_getlastoid. http://www.php.net/manual/function.pg-exec.php

« previous php.notes (#2093) next »