I have simple question.
What is faster for performance?
A) Blank "insert into" with auto-increment to INNODB. (only 1 column in table, id(int)) and return that last id via PHP function mysql_insert_id();
$db=mysql_query("insert into `system_id` () VALUES()",$GLOBALS["dbspojenie"]);
$id = mysql_insert_id();
return $id;
B) UPDATE id and after, select that id from same row? (MYISAM)
$db=mysql_query("UPDATE `system` SET `id`=`id`+1",$GLOBALS["dbspojenie"]);
$db=mysql_query("select `id` from `system`",$GLOBALS["dbspojenie"]);
while($zaznam=mysql_fetch_array($db)):
$id=$zaznam["id"];
endwhile;
return $id;
I have used INNODB in A) because of row locking.
It is just question, thank you for answering. :)
select max(`id`) as 'id' fromsystem`` would only return a single result, so you'd eliminate the loop, but it's still unsafe