【发布时间】:2013-08-30 10:37:29
【问题描述】:
如果我使用这个 SQL:
UPDATE formulare SET EV_id=59, EV_status=5 WHERE EV_id=57 AND ID_uziv=12;SELECT LAST_INSERT_ID();
我会得到0 作为最后一个插入ID。
我正在使用 php mysqli_insert_id,据说:
The mysqli_insert_id() function returns the ID generated by a query
on a table with a column having the AUTO_INCREMENT attribute.
If the last query wasn't an INSERT or UPDATE statement
or if the modified table does not have a column with the AUTO_INCREMENT attribute,
this function will return zero.
我的表formualre 有auto increment 列,所以我不知道问题出在哪里
【问题讨论】:
-
update 不会给你最后的插入 id。它只会给你更新的记录数。最后的插入 id 只用于插入
-
last_insert_id应该告诉你任何你需要知道的事情。没有插入任何东西。所以没有返回ID。 -
你能链接到你引用的文档吗?
-
documentation here 我对您的回答在@dystroy 回答下
标签: php sql last-insert-id