note 9198 added to pg_exec
| From: | brooke at jump dot net | Date: | Sun, 22 Oct 2000 16:49:59 +0000 |
| Subject: | note 9198 added to pg_exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6825@lists.php.net to get a copy of this message | ||
A lot of people have griped about getLastOid vs. other methods. Here's the real deal:<br>
One of the many greatnesses of Postgres is Declarative Referential Integrity, available in versions
with major number 7 and up. Unfortunately in the beta versions I tried, you could not declare
referential integrity against the oid attribute of a table. Therefore, you had to use an explicit
"id" field. You could use a serial type (ie default value=nextval(series)) but then if you
want the generated ID, you have to do a table lookup to find it. The right way to do it is to
explicitly read nextval(sequence) and use it. If somebody gives you holes in your sequence,
that's totally OK and a fact of life. It's the only tradeoff which is both fast and
correct.
http://www.php.net/manual/function.pg-exec.php