Re: Add a record and recover it's ID in one operation

From: Date: Thu, 13 Feb 2003 21:17:38 +0000
Subject: Re: Add a record and recover it's ID in one operation
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-135525@lists.php.net to get a copy of this message
Thanks! I stand corrected. I'll check the PHP online manual more often, and for now, I'm off to optimise my database and rewrite a few queries :) Cheers, Daniel "Leif K-Brooks" <eurleif@buyer-brokerage.com> a écrit dans le message de news: 3E4C0938.8070703@buyer-brokerage.com... > www.php.net/mysql-insert-id > > Daniel Page wrote: > > >Hi, > > > >Imagine a table with an auto-increment id number field and a text field for > >the username. > >User B (with user name 'johnny') could write to the database a millisecond > >after user A, with the same username. When user A looks for the last record > >written by Johnny, A will find the record entered by B. > > > >Is there a way to directly recover the auto-incremented number as like a > >return value (or somthing like that) of the write query as to be able to > >identify immediately what record you just wrote? > > > >This is just for argument's sake - I just would like to know if it is > >possible. My current solution is inserting the login time of the current > >user and/or IP, and adding that to make a temporary ID key where you select > >the latest entry written where username = your username and login time > >string = hhmmss info so you can immdately find your latest entered data, > >though recovering immediately the ID would have been a more elegant solution > >for this. > > > >Cheers, > >Daniel > > > > > > > > > > > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. > > >

« previous php.general (#135525) next »