您确定您执行的最后一个查询是INSERT吗?
mysqli->insert_id
似乎是正确的答案:
Return Values
The value of the
AUTO_INCREMENT
field that was updated
by the prev@R_403_437@s query. Returns zero if
there was no prev@R_403_437@s query on the
connection or if the query did not
update anAUTO_INCREMENT
value.