Db\Adapter\Pdo::lastInsertId

public int | boolean lastInsertId ([string $sequenceName])

Returns the insert id for the auto_increment/serial column inserted in the lastest executed SQL statement

//Inserting a new robot
 $success = $connection->insert(
     "robots",
     array("Astro Boy", 1952),
     array("name", "year")
 );

 //Getting the generated id
 $id = $connection->lastInsertId();
doc_Phalcon
2016-10-16 09:49:07
Comments
Leave a Comment

Please login to continue.