[eluser]PhilTem[/eluser]
If you want to receive the last inserted ID (after an insert-query) you may also use
Code:
$last_id = $this->db->last_insert_id();
However, @Stefan's code works well for auto-incrementing tables. If you tend to use your own primary-key, you'd have to have a field which annotates the creation date or its time stamp by which you would sort DESC and limit it to (1,1) while selecting the primary-key field.