For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > November 2004 > Re: [PEAR] DB_Object->insert() not returning ID









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] DB_Object->insert() not returning ID
Justin Patrin

2004-11-29, 8:56 pm

On Mon, 29 Nov 2004 15:19:15 -0800, Ken Restivo <ken@restivo.org> wrote:
> On Mon, Nov 15, 2004 at 10:46:12AM -0800, Justin Patrin wrote:
>
> Thanks. The API docs also have the wrong information in the main body (about returning the last inserted ID), but with a note that says "mysql-specific? fixme". My fault for missing that, I guess. It does describe the return value correctly.
>
> I read somewhere that the inserted ID gets inserted into the object after the ->insert(). Is that a reliable, safe way to get the last inserted ID?
>
> I think what I'm saying is, I can't believe that I have to write a utility function (and then subclass DBDO or copy/paste it) to get the last inserted ID. It seems like a very common thing and somewhere in the DBDO docs I must have overlooked the "offic

ially-approved" way to do it.
>


When I use DB_DataObject (please call it that, not DB_Object) the id
is in the object after the insert() call. Of course, I'm using mysql.
I have no idea about other RDBMS.

--
Justin Patrin
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com