RE: php/mysql - getting ID of query
| From: | John Pillion | Date: | Tue, 21 Aug 2007 22:04:25 +0000 |
| Subject: | RE: php/mysql - getting ID of query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261098@lists.php.net to get a copy of this message | ||
Thanks guys, that's exactly what I was looking for
J
-----Original Message-----
From: M. Sokolewicz [mailto:tularis@php.net]
Sent: Tuesday, August 21, 2007 4:51 PM
To: John Pillion
Cc: php-general@lists.php.net
Subject: Re: php/mysql - getting ID of query
John Pillion wrote:
> This is as much a mysql question as it is php.
>
>
>
> What is the most reliable way to retrieve an auto_increment key/id for a
> query you just inserted?
>
>
>
> In other words, I compile all my data, insert it into a new row, and now I
> want to retrieve the ID it created for it in the ID/key field. Without
> turning around and searching for the values I just inserted, is there a
way
> to get the ID? The ID is the only field that is guaranteed to be unique
in
> each data set, which makes it questionable to search for the data you just
> inserted, unless you searched for the *whole* data set.
>
>
>
> Thanks
>
>
>
> John
>
>
mysql_insert_id()
mysqli::insert_id
PDO::lastInsertId()
depending on the way you access it.