you can use function lastInsertId()
$sSQL = "INSERT INTO Commande $champs VALUES $value ";
$query = new Query($sSQL,$this->getDI());
$ret = $query->execute();
$lastId = $query->lastInsertId();
Update
Here is an example of inserting and returning the lastinsert id.
$success = $connection->insert(
"robots",
array("Astro Boy", 1952),
array("name", "year")
);
$id = $connection->lastInsertId();
I think this may help you.
source
share