Welcome Guest, Not a member yet? Register   Sign In
Feature Request:
#4

[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.


Messages In This Thread
Feature Request: - by El Forum - 01-13-2008, 07:19 PM
Feature Request: - by El Forum - 01-13-2008, 08:56 PM
Feature Request: - by El Forum - 01-14-2008, 12:43 AM
Feature Request: - by El Forum - 01-14-2008, 01:10 AM
Feature Request: - by El Forum - 01-14-2008, 01:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB