问题
which one is the correct code in a prepared statement? $ID_user=$mysqli->insert_id;
or $ID_user=$stmt->insert_id;
?
$stmt = $mysqli->prepare("INSERT INTO users (first_name, last_name) VALUES (? ,?)");
$stmt->bind_param("ss",$first_name,$last_name);
if($stmt->execute())
{
$ID_user=$mysqli->insert_id; // or $ID_user=$stmt->insert_id;
}
回答1:
There is absolutely no difference, you can use whatever you wish.
来源:https://stackoverflow.com/questions/43184732/mysqli-insert-id-mysqli-insert-id-or-id-user-stmt-insert-id