note 71603 added to function.mysql-insert-id

From: Date: Thu, 07 Dec 2006 12:15:52 +0000
Subject: note 71603 added to function.mysql-insert-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-120370@lists.php.net to get a copy of this message
In response to rudolflai at gmail dot com (11-Sep-2006 11:59) >> Below is a snippet for retriving the next insert id from a mysql table. >> It functions like the auto_increment option in phpMyAdmin. Sorry, that's not true! Your function simply reads the maximum id value of an currently existing row in the table. In case of deleting the maxium value the next lower id value is used - and that's not the way how auto_increment works. So better use the MySQL "SHOW TABLE STATUS" like this: $SQL = "SHOW TABLE STATUS FROM databaseName LIKE 'tableName'"; $result = mysql_query($SQL); $row = mysql_fetch_assoc($result); $nextInsertId = $row['Auto_increment']; Yves Vogl ---- Server IP: 212.124.37.9 Probable Submitter: 83.135.28.134 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php Edit -- https://master.php.net/note/edit/71603 Del: integrated -- https://master.php.net/note/delete/71603/integrated Del: useless -- https://master.php.net/note/delete/71603/useless Del: bad code -- https://master.php.net/note/delete/71603/bad+code Del: spam -- https://master.php.net/note/delete/71603/spam Del: non-english -- https://master.php.net/note/delete/71603/non-english Del: in docs -- https://master.php.net/note/delete/71603/in+docs Del: other reasons-- https://master.php.net/note/delete/71603 Reject -- https://master.php.net/note/reject/71603 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120370) next »