Skip to main content
Version: Fegg 5.x (next)

Pdo::getLastIndexId

Get the last inserted id of executed insert query

Description​

public string Pdo::getLastIndexId()

Returns the ID generated by the last INSERT on the connection (PDO::lastInsertId()), as a string. Call it on the same instance, right after execute.

Example​

Controller
$db = new \Fegg\Database\Pdo();

$db->setValues(array('title' => 'Sample'))->insert('cms_news')->execute();
$id = (int) $db->getLastIndexId();
// -> 24