Re: Re: last insert ID
| From: | Zu3Bi | Date: | Tue, 18 Jan 2005 08:46:01 +0000 |
| Subject: | Re: Re: last insert ID | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38198@lists.php.net to get a copy of this message | ||
You can use the mysql_insert_id() function, it returns the id generated by the last query executed on the connection... hope this helps..
Zu3Bi
I was having trouble with retrieving the last insert id as well. Even after looking over the information in the link, I couldn't figure out how to make this work in PHP. Using the statement: $id = $link->query("SELECT LAST_INSERT_ID()"); $id turned out to be a huge array - no part of which seemed to contain the expected 'last id'. I can't even determine if I got any part of it right. Does anyone have a more complete example? I'm lost. I'm surprised that the DB library doesn't do this. Is there some reason that it cannot or is it just waiting for someone to write the code? Thank you for any assistance, Nelson