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值?
發佈lastInsertId函數。 –
http://php.net/manual/en/pdo.lastinsertid.php – Alex
這些值實際上是否被插入? – konsolenfreddy