• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple models (one for each row)

#1
[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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.