我正在尝试插入到我的数据库中,它工作得很好,但是LastInsertId总是显示为0,你有什么想法?
$stmt = $db->prepare('INSERT INTO players_results (matchweek_id, matchweek, game_id, username, homeresult, awayresult, goals, submit, matchweek_session) Values (:matchweekid, :matchweek, :gameid, :username, :homeresult, :awayresult, :goals, :submit, :matchweeksession)');
for ($gi = 1; $gi <= 10; $gi++) {
$stmt->execute(array(
':matchweekid' => '1',
':matchweek' => 'Matchweek 1',
':gameid' => $gi,
':username' => $_POST['username'],
':homeresult' => NULL,
':awayresult' => NULL,
':goals' => NULL,
':submit' => 'n',
':matchweeksession' => 'open'
));
$id = $db->lastInsertId('member_id');
}发布于 2017-08-09 20:26:34
//更改
$id = $db->lastInsertId();至
$id = $stmt->lastInsertId();https://stackoverflow.com/questions/45590286
复制相似问题