Longhorn PHP 2025 - Speakers and Schedule Announced!

Voting

: max(four, four)?
(Example: nine)

The Note You're Voting On

Nick Baicoianu
18 years ago
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
?>

<< Back to user notes page

To Top