How to get the lastinsertid Doctrine

This example show how you can get the latest insert id on table continent.


$dbh = Doctrine_Manager::getInstance()->getCurrentConnection();
$sth = $dbh->prepare("INSERT INTO continent (created_at, updated_at) VALUES ( NOW(), NOW() )");
$sth->execute();

$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
$conn->lastInsertId('continent_id');

Comments

thanks

i wasted so many hours looking for this code.. thanks a lot.