![]() |
how do I represent a collection of models? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: how do I represent a collection of models? (/showthread.php?tid=24616) |
how do I represent a collection of models? - El Forum - 11-14-2009 [eluser]jared4444[/eluser] I have records in database table called payments. I have a model called payments_model which has the same fields as the db. I have a function in the model that gets a payment from the db by id function getpaymentbyid($id) if ($query->num_rows() > 0) { $row = $query->row(); $this->ID = $row->ID; $this->name = $row->name; How do I get more than one row in the db and return that? Do I make a model which contains an array of this model? Is there another option? how do I represent a collection of models? - El Forum - 11-14-2009 [eluser]The Casual Bot[/eluser] if it gets the record by the id the id should be unique?? if you get lets say the invoices from today then you would return Code: $query->results how do I represent a collection of models? - El Forum - 11-15-2009 [eluser]überfuzz[/eluser] @jared - You could always show us the query. Might be easier to help you then. |