[solved] Multiple instances of a model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [solved] Multiple instances of a model (/showthread.php?tid=64688) |
[solved] Multiple instances of a model - Fred9176 - 03-21-2016 Hi, I would like to know if it was possible to have multiple instances of the same model in a controller. For exemple, I'dlike to do something like that : $objects = array(); for($i = 1;$i < 10; $i++){ $objects[] = new Objectmodel($i); } The only way I found to do that is to include the corresponding model file in the controller php file and remove the "extends My_Model". Is there a better way to do that using a more CI compliant manner ? Thank you for your help, Fred RE: Multiple instances of a model - Narf - 03-21-2016 Load it once the regular way before trying to directly instantiate it. RE: Multiple instances of a model - Fred9176 - 03-21-2016 Thank you very much, it works fine :-) |