[eluser]Michael Wales[/eluser]
Ah yes - I see what you mean. One way to get around this is to place it within your model methods (this is usually what I do). Yeah, you're still hitting the database another time but you'd be hitting the database another time no matter what (since MySQL doesn't return the new ID upon INSERT). It's kind of a work around way and adds another layer of abstraction on top of what you are asking for, but depending on how your application is structured it may be a good solution.
Some demo code:
Code:
function newUser($username = '') {
$result = $this->db->insert('users', array('username'=>$username));
if ($this->db->affected_rows() > 0) {
return $this->db->insert_id();
} else {
return FALSE;
}
}
Of course, you could always extend the core and just override the insert() method within the DB driver. That would prevent you from adding in the layer of abstraction.