[UPHPU] Postgres Insert ID

thebigdog bigdog at venticon.com
Wed Oct 22 15:18:41 MDT 2008


> I'm not having any luck finding the equivalent to mysqli_insert_id() for
> postgres. I've seen the method of getting the id from the sequence, but I'm
> hoping for a better way to do then that...

technically, there is not a php function in postgesql like that function. you
can write a query to provide that information based on the sequence that you are
using.

select currval('sequence_name');

that will return the last value used. however, there is not a php function that
will provide the functionality that mysqli_insert_id() does.

here is some additional info on it:

http://archives.postgresql.org/pgsql-general/2003-08/msg01699.php
http://www.postgresql.org/docs/8.2/static/functions-sequence.html


-- 
thebigdog


More information about the UPHPU mailing list