Reliable or not PDO lastInsertId() when using transactions
问题 I use PDO transaction try { DB::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); DB::$db->beginTransaction(); $db->prepare( insert query ); $db->execute(); $last_insert_id = $db->lastInsertId(); ... ... Multiple concurrent requests are expected on this script. Question: is it possible that lastInsertId() return incorrect value for the user, who actually inserted the row? (by "incorrect value" i mean: id that is inserted by some other user). 回答1: You're safe. The ID you get will