tags:

views:

32

answers:

3

Is there a way with Pear DB to return the ID of a newly INSERTED record?

+1  A: 

Does this work?

$id = $db->getOne('SELECT LAST_INSERT_ID()');
p.campbell
+2  A: 

Yes, last_insert_id() is the answer to your question. It's session specific, so you don't have to worry if the id returned is the id from another row inserted by another user. You will be sure it's the one you need.

Vasileios Lourdas
+1  A: 

Not really answering your question as such but the DB package has been deprecated for a very long time - you are better off to be using the MDB2 package which is actively maintained - the latest release was last month.

kguest