Re: mysql_insert_id?

From: Date: Wed, 16 Jan 2002 17:53:24 +0000
Subject: Re: mysql_insert_id?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80771@lists.php.net to get a copy of this message
on 1/16/02 10:47 AM, Jimmy at jimmy@spacedisk.com wrote: > Hi DL, > >>> the only problem i can think of might occur with pconnect is, >>> last_insert_id() will return you the last inserted ID from >>> previous 'session', not current 'session'. >>> to prevent this, you should call last_insert_id() only when >>> your INSERT query executed succesfully. > >> =Of course a "right-living" boy like me, cannot conceive of why one would >> look up LAST_INSERT other than immediately after the INSERT/UPDATE command... > > calling last_insert_id() after INSERT is the number one rule > of course :) > What i mean was, what if the INSERT query fail, but the script still > execute the last_insert_id() function? > Most probably the returned value would be wrong, because it will > return the last_insert_id of previous INSERT query (from previous > 'session') but of course, you'd have checked that the result id returned a valid result and not an error in this case and never looked for the last_insert_id, right? ;) mike -- mike cullerton michaelc at cullerton dot com

« previous php.general (#80771) next »