note 7855 added to pg_exec
| From: | ron at opus1 dot com | Date: | Thu, 17 Aug 2000 09:04:58 +0000 |
| Subject: | note 7855 added to pg_exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-2061@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
sessiuon/pageload/whatever, you can wind up with odd holes in the db.
Hence, pg_getlastoid.
http://www.php.net/manual/function.pg-exec.php