Welcome Guest, Not a member yet? Register   Sign In
Which ORM use alongside codeigniter
#2

[eluser]alexwenzel[/eluser]
I also have had a lot of thoughts about which ORM i should use. I tried Datamapper and Doctrine, but there were always a point where it start to suck.

So I decided to stick with CodeIgniter Active Records and wrote a CRUD Model myself (link in my signature).

Code:
// INSERT data
$user           = new User();
$user->name     = 'new user';
$user->email    = '[email protected]';
$user->password = '123456';
$user->save();

// UPDATE data
$user = User::find('name', 'new user');
$user->password = 'new password';
$user->save();

// REMOVE data
$user = User::find('id', 1);
$user->remove();

This reads like a ORM but is only a CRUD Model-Override. So performance is almost the same like using CodeIgniter Active Records.

Now the interesting Part for you:

You can easily extend the model to add entities or ORM-like behaviour.

Code:
class User extends MY_Model {

  public function getRole() {
    return User_Role::find('id', $this->role_id);
  }

}

class User_Role extends MY_Model {

}

Just as an quick example.

Advantage of this method is:

- You have full controll of the behaviour
- You have the performance of CodeIgniter Active Records

Just my 2 cents on this topic.


Messages In This Thread
Which ORM use alongside codeigniter - by El Forum - 10-14-2012, 11:30 AM
Which ORM use alongside codeigniter - by El Forum - 10-14-2012, 11:49 AM
Which ORM use alongside codeigniter - by El Forum - 10-14-2012, 02:18 PM
Which ORM use alongside codeigniter - by El Forum - 10-14-2012, 04:17 PM
Which ORM use alongside codeigniter - by El Forum - 10-15-2012, 03:24 AM
Which ORM use alongside codeigniter - by El Forum - 10-15-2012, 11:29 AM
Which ORM use alongside codeigniter - by El Forum - 10-15-2012, 11:38 AM
Which ORM use alongside codeigniter - by El Forum - 10-15-2012, 07:43 PM
Which ORM use alongside codeigniter - by El Forum - 10-15-2012, 11:53 PM
Which ORM use alongside codeigniter - by El Forum - 10-22-2012, 06:40 AM
Which ORM use alongside codeigniter - by El Forum - 10-23-2012, 04:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB