note 70805 added to function.mysql-insert-id

From: Date: Sun, 29 Oct 2006 08:57:11 +0000
Subject: note 70805 added to function.mysql-insert-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-119222@lists.php.net to get a copy of this message
It's not true that mysql_insert_id() only returns the ID generated for an AUTO_INCREMENT column by the previous INSERT query. We can use LAST_INSERT_ID() statement that will return value for mysql_insert_id(). Example: $sql = "UPDATE mytable SET mytable_id= LAST_INSERT_ID(mytable_id + 1) WHERE ...; @mysql_query($sql); $last_id = mysql_insert_id(); LAST_INSERT_ID() statement will affect mysql_insert_id(). Regards, Buana ---- Server IP: 202.158.56.242 Probable Submitter: 61.94.124.129 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php Edit -- https://master.php.net/note/edit/70805 Del: integrated -- https://master.php.net/note/delete/70805/integrated Del: useless -- https://master.php.net/note/delete/70805/useless Del: bad code -- https://master.php.net/note/delete/70805/bad+code Del: spam -- https://master.php.net/note/delete/70805/spam Del: non-english -- https://master.php.net/note/delete/70805/non-english Del: in docs -- https://master.php.net/note/delete/70805/in+docs Del: other reasons-- https://master.php.net/note/delete/70805 Reject -- https://master.php.net/note/reject/70805 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119222) next »