0
我有这个的phpmyadmin和mysql PDO lastInsertId()
$query = "INSERT INTO players VALUES (
UUID(),
:firstname,
:lastname,
:age,
:birthplace,
:height,
:weight,
:bats,
:throws,
:position,
:jersey,
:status,
:team,
:image_path
)";
$sth = $db->prepare($query);
$sth->execute(array(
':firstname' => $firstname,
':lastname' => $lastname,
':age' => $age,
':birthplace' => $birthplace,
':height' => $height,
':weight' => $weight,
':bats' => $bats,
':throws' => $throws,
':position' => $position,
':jersey' => $jersey,
':status' => $status,
':team' => $team,
':image_path' => $image_path
));
$id = $db->lastInsertId();
return $id;
,我试图返回插入的最后一个ID,和所有我得到的是一个0返回。 任何帮助将不胜感激 谢谢
首先检查,如果执行成功。因为如果不是,那么0可能是正确的,对吗? – hakre
是的执行工作和一切,行得到正确添加到数据库 –