Welcome Guest, Not a member yet? Register   Sign In
Codeigniter and DMZ`
#1

[eluser]The Mask[/eluser]
Hi,
Can anyone please advise the recommended method for loading models using Datamapper?

Should I still be using the Codeigniter loader and then reference my models as:
$this->load->model( 'Foo' );
$this->Foo->bar();
or do I now need to use the following as in the documentation:
$foo = new Foo();
$foo->bar();

Thanks
#2

[eluser]BrianDHall[/eluser]
You should use the latter form, for many reasons, but most specifically and simply the latter method allows you to have more than one Foo - and you'll often find you need such functionality when you least expect it.

Code:
$user = new User();
$user->get_where('username', 'shuckyducky');
$user->sig_line = 'Shucky!';
$user->save();

if ($command == 'delete')
{
$user->delete();
}

Also it is a lot less code to right to avoid use of $this->User - you could just have $user or even just $u.




Theme © iAndrew 2016 - Forum software by © MyBB