왜?lastInsertId()는 빈 문자열을 반환합니다.
try{
$st = $this->prepare("INSERT INTO thetable (a,b) VALUES (?,?)");
$st->execute(array(5,5));
$id = $this->lastInsertId();
echo $id; // nothing
echo gettype($id); // string
return $id; // and I get NULL returned, this is even weirder...
}catch(PDOException $e){
die($e);
return false;
}
테이블에 자동 증가가있는 id 열이 있습니다. Id 값을 얻지 않는 이유는 무엇입니까? 대신
$this->lastInsertId();
의
lastInsertId 함수를 게시하십시오. –
http://php.net/manual/en/pdo.lastinsertid.php – Alex
값이 실제로 삽입 되나요? – konsolenfreddy