您确定您执行的最后一个查询是INSERT吗?
原文链接:https://www.f2er.com/php/240240.htmlmysqli->insert_id
似乎是正确的答案:
Return Values
The value of the
AUTO_INCREMENT
field that was updated
by the prevIoUs query. Returns zero if
there was no prevIoUs query on the
connection or if the query did not
update anAUTO_INCREMENT
value.