Posted by David Haynes on 07/11/06 10:24
Julian Moorhouse wrote:
> Hi,
>
> I'm fairly new to mysql, but I have a reasonable knowledge of PHP.
>
> I just want to know is theres a simple way to return a primary key
> value for a record I've just inserted?
>
> In other environments I'd set a flag using the current time stamp which
> is inserted with the record.
>
> Then I'd select on that timestamp and get the primary key value.
>
> Is there a simpler way?
>
> Jules.
>
If your primary key is made using AUTO_INCREMENT, you may use the
mysqli_insert_id function.
http://ca.php.net/manual/en/function.mysqli-insert-id.php
-david-
Navigation:
[Reply to this message]
|