Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 200003

[PHP3] PostgreSQL Object ID from INSERT From: Andrew Hill (list <email protected>)
Date: 03/10/00

Hi,

I've set up a table in PostgreSQL using a serial SEQUENCE as a primary
key.

Using PHP, I insert information into the database by using:

  $result = pg_exec ($database, "INSERT INTO.... ;");

where $database is the database in question, and all information except
the field for the serial SEQUENCE is inserted.

What I need to do now is to be able to now do a SELECT on that new
entry, so I can get the number that PostgreSQL has assigned for the
SEQUENCE.

I know I can use:

  $oid = pg_getlastoid ($result);

to get the Object ID of the last INSERT that was done, but I am not
clear on how I can use $oid to now select the SEQUENCE field from that
recently inserted row.

Ideas?

TIA,

-- 

Andrew Hill

-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>