note 74923 added to function.mysqli-insert-id

From: Date: Fri, 04 May 2007 08:10:09 +0000
Subject: note 74923 added to function.mysqli-insert-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-126191@lists.php.net to get a copy of this message
When running extended inserts on a table with an AUTO_INCREMENT field, the value of mysqli_insert_id() will equal the value of the *first* row inserted, not the last, as you might expect. <? //mytable has an auto_increment field $db->query("INSERT INTO mytable (field1,field2,field3) VALUES ('val1','val2','val3'), ('val1','val2','val3'), ('val1','val2','val3')"); echo $db->insert_id; //will echo the id of the FIRST row inserted ?> ---- Server IP: 64.71.164.2 Probable Submitter: 69.235.234.185 ---- Manual Page -- http://www.php.net/manual/en/function.mysqli-insert-id.php Edit -- https://master.php.net/note/edit/74923 Del: integrated -- https://master.php.net/note/delete/74923/integrated Del: useless -- https://master.php.net/note/delete/74923/useless Del: bad code -- https://master.php.net/note/delete/74923/bad+code Del: spam -- https://master.php.net/note/delete/74923/spam Del: non-english -- https://master.php.net/note/delete/74923/non-english Del: in docs -- https://master.php.net/note/delete/74923/in+docs Del: other reasons-- https://master.php.net/note/delete/74923 Reject -- https://master.php.net/note/reject/74923 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126191) next »