How to get the last Inserted Id using the Joomla! Platform

After you performed an Insert statement use the insertid method to get the auto-incremented value from the last Insert statement

$db = $this->getDbo();
$query  = $db->getQuery(true);
//Now we get the last inserted id
$lastInsertId = $db->insertid();
echo $lastInsertId;

Note in the above code we used $db->insertid(); to obtain the last inserted id.

Image Credits: Photo by Isis França on Unsplash.

More Similar Posts

No results found.