List:General Discussion« Previous MessageNext Message »
From:Curtis Maurand Date:August 22 2001 7:17pm
Subject:Re: LAST_INSERT_ID()
View as plain text  
A caveat is that you get the last_insert_id for your connection.  Not the
last one in the database.

Curtis

On Wed, 22 Aug 2001, Dr. Werner Stürenburg wrote:

>
>
> Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 14:57:06:
>
> > At 13:19 22.8.2001 +0200, you wrote:
> >>LAST_INSERT_ID() should return the last autoincrement value of
> >>the last insert
>
> > Yep it sure did, managed to get to machine and test it out. Total mess.
>
> > but;
>
> > $query = "SELECT LAST_INSERT_ID()";
> > $result = mysql_query($query);
> > if ($result) {
> > $nrows = mysql_num_rows($result);
> > $row = mysql_fetch_row($result);
> > $lastID = $row[0];
> > }
>
> > was a code sent to me and if it helps anyone there it is, do not know who
> > is the original author but this takes the Id from first insert in you put
> > it after it and then you can use the $lastID in following inserts, works fine.
>
> Why not use mysql_insert_id(); ????
>
>

Thread
LAST_INSERT_ID()Jari Mäkelä22 Aug
  • Re: LAST_INSERT_ID()Dr. Werner Stürenburg22 Aug
    • Re: LAST_INSERT_ID()Jari Mäkelä22 Aug
      • Re: LAST_INSERT_ID()Dr. Werner Stürenburg22 Aug
        • Re: LAST_INSERT_ID()Curtis Maurand22 Aug
          • Re: LAST_INSERT_ID()Werner Stürenburg22 Aug