note 35117 added to function.mysql-insert-id
| From: | M at starone dot co dot uk | Date: | Wed, 20 Aug 2003 10:05:15 +0000 |
| Subject: | note 35117 added to function.mysql-insert-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54737@lists.php.net to get a copy of this message | ||
There seems to be some pretty inconsistent results generated by using last_insert_id() or
last_insert_id(fieldname).
If u want to get the last inserted id value from an auto incremented field try ..
$idQuery = "select id from users order by -id limit 0,1";
$result = mysql_query($idQuery);
$row = mysql_fetch_row($result);
$m_id = $row[0]; ///$m_id is now the value of the last insert in the id field
$m_id++; //$m_id is now the correct value for the next insert call
hope this helps someone :o)
l8r,
M
----
Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35117
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35117&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35117&report=yes