CodeIgniter Forums

Full Version: [solved] Multiple instances of a model
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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,

Load it once the regular way before trying to directly instantiate it.
Thank you very much, it works fine :-)