Assuming you are using MySQL, after performing the insert, you can execute the following query:
$array_with_id = $this->query('select last_insert_id() as id;');
But, as kouak mentioned, the usual way to insert data is to use the save () method. If you use this method, then the identifier of the inserted record will be automatically available in the $ id property of the corresponding model.
dhofstet
source share