Welcome Guest, Not a member yet? Register   Sign In
[solved] Multiple instances of a model
#1

(This post was last modified: 03-22-2016, 05:30 AM by Fred9176.)

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
Reply
#2

Load it once the regular way before trying to directly instantiate it.
Reply
#3

Thank you very much, it works fine :-)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB