note 35117 rejected from function.mysql-insert-id by didou
| From: | didou@php.net | Date: | Wed, 20 Aug 2003 10:33:34 +0000 |
| Subject: | note 35117 rejected from function.mysql-insert-id by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54738@lists.php.net to get a copy of this message | ||
Note Submitter: M@starone.co.uk
----
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