[nycphp-talk] PEAR::DB insertID???
Christopher R. Merlo
cmerlo at ncc.edu
Tue Mar 30 10:42:58 EST 2004
On 2004-03-30 09:13 -0600, Eric Rank <erank at isthmus.com> wrote:
> I haven't looked extensively at the PEAR documentation, but from what I did
> see, I couldn't find a means of getting an inserted ID after an insert
> query. Using mysql_insert_id($dbh->connection) works, but abstracting away
> from db-specific code is the whole point of PEAR::DB right? Any thoughts?
I'm not using PEAR::DB (yet), but what I do with MySQL when I need to
find this out is:
1) Lock the table
2) Insert what needs to get inserted
3) Query the ID out of the table order by id desc limit 1
4) Unlock the table
This assumes, of course, that your IDs are auto_increment.
HTH,
-c
--
cmerlo at ncc.edu http://turing.matcmp.ncc.edu/~cmerlo
Windows: You'll wish we were kidding.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040330/606018fc/attachment.sig>
More information about the talk
mailing list