par
mcorgnet » 25 avr. 2008, 10:19
Bonjour,
Je cherche à récupérer le dernier id inséré après un pdostatement.
$stmt = Chrono::$myConnexion->prepare("REPLACE INTO participants (id, nom, prenom) values (:id, :nom, :prenom)");
$stmt->bindParam(":id", $this->id);
$stmt->bindParam(":nom", $this->nom);
$stmt->bindParam(":prenom", $this->prenom);
$stmt->execute();
si je fais :
$stmt->lastInsertId();
J'ai une erreur :
Fatal error: Call to undefined method PDOStatement::lastInsertId() in
En gros, sur un pdostatement, lastinsertid ne fonctionne pas ... Et si je le fais
Chrono::$myConnexion->lastInsertId();
ça me retourne toujours 0 ...
Je pense que c'est à cause de mon "replace" ... Mais comment régler le problème ?
Bonjour,
Je cherche à récupérer le dernier id inséré après un pdostatement.
[php]
$stmt = Chrono::$myConnexion->prepare("REPLACE INTO participants (id, nom, prenom) values (:id, :nom, :prenom)");
$stmt->bindParam(":id", $this->id);
$stmt->bindParam(":nom", $this->nom);
$stmt->bindParam(":prenom", $this->prenom);
$stmt->execute();
[/php]
si je fais :
[php]$stmt->lastInsertId();[/php]
J'ai une erreur :
Fatal error: Call to undefined method PDOStatement::lastInsertId() in
En gros, sur un pdostatement, lastinsertid ne fonctionne pas ... Et si je le fais
[php]Chrono::$myConnexion->lastInsertId();[/php]
ça me retourne toujours 0 ...
Je pense que c'est à cause de mon "replace" ... Mais comment régler le problème ?