CodeIgniter Forums
multiple models (one for each row) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: multiple models (one for each row) (/showthread.php?tid=53814)



multiple models (one for each row) - El Forum - 08-10-2012

[eluser]Sweden[/eluser]
Hello!

I have a problem where I would like each model to represent a row in the table, so that a user example can be loaded like this:
Code:
$this->load->model("User_model", "User");
$this->User->GetFromID(1);
echo $this->name;

This works fine, however now I want to get say 10 users from the table and for each row I wanna create a user object. What is the easiest way to do this?

What I've been using prevously looks like this:
Code:
while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
//fetch object instead?
}

Not sure if thats any helpful, let me know if there is something not clear