Re: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Sancar Saran
On Friday 20 July 2007 21:10:28 Marcelo Wolfgang wrote: > Hi all, > > I'm a newbie in PHP, and I want to know what's the best technique you > guys use when you need to get the id of the last inserted value in the > database. > > My first thought is to do a SELECT on the db and get the last id, but

Re: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Richard Lynch
On Fri, July 20, 2007 2:42 pm, Nathan Nobbe wrote: > im not sure, but i think you still want to surround the insert and the > db > specific call to get the > last insert id within a transaction. ID generation and uniqueness thereof is SOOO common, that most (all?) the DBs support it without wrappi

RE: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Richard Lynch
On Fri, July 20, 2007 2:07 pm, Uber Wannabe wrote: > However, wouldn't obtaining the id in that manner still possibly lead > to > duplication? The DB would take care of the locking on the inserts, > but the > inserts would be populated from a non-locking select, right? Which No. In the case of

Re: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Nathan Nobbe
he DB's built-in functionality for that. As usual, all the information on that is freely available online. -- N/A -Original Message- From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: Friday, July 20, 2007 1:50 PM To: Marcelo Wolfgang Cc: php-general@lists.php.net Subject: Re: [PHP] best te

RE: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Uber Wannabe
0, 2007 1:50 PM To: Marcelo Wolfgang Cc: php-general@lists.php.net Subject: Re: [PHP] best technique to get the ID of the last inserted value One easy solution would be to get the ID before you do the insert i.e. in Oracle you would run the query: select some_id_generating_seq.nextval from dua

Re: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Brad Bonkoski
One easy solution would be to get the ID before you do the insert i.e. in Oracle you would run the query: select some_id_generating_seq.nextval from dual and then you would use that id to insert and you would know the id after that...and the DB would take care of locking and such. So, check

Re: [PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Richard Lynch
On Fri, July 20, 2007 1:10 pm, Marcelo Wolfgang wrote: > I'm a newbie in PHP, and I want to know what's the best technique you > guys use when you need to get the id of the last inserted value in the > database. > > My first thought is to do a SELECT on the db and get the last id, but > I > know th

[PHP] best technique to get the ID of the last inserted value

2007-07-20 Thread Marcelo Wolfgang
Hi all, I'm a newbie in PHP, and I want to know what's the best technique you guys use when you need to get the id of the last inserted value in the database. My first thought is to do a SELECT on the db and get the last id, but I know that if I have two almost simultaneous connections I may