Welcome Guest, Not a member yet? Register   Sign In
Multiple models in 1 variable
#1

[eluser]Unknown[/eluser]
I got this problem
i need to load a model dynamically

like this
Code:
$this->load->model($fila_destino->nombre,'tabla_temp');
$data2=$this->tabla_temp->loggin($data->idusuario);
being $fila_destino->nombre, the name of the model to charge, but when i call the function loggin of tabla temp (the second line of the code), it's always charge the first model (the bug occurs when the $fila_destino->nombre it's different than the first time it's called.
An example. i need to load in the first time the model "model1" and load in 'tabla_temp'
and the second time to "model2" and load to in "tabla_temp" but, the second time the model "model2" doesn't load on 'tabla_temp' besides 'tabla_temp' it's an instance of "model1".



#2

[eluser]TWP Marketing[/eluser]
[quote author="Ernesto2456" date="1345570527"]I got this problem
i need to load a model dynamically

like this
Code:
$this->load->model($fila_destino->nombre,'tabla_temp');
$data2=$this->tabla_temp->loggin($data->idusuario);
being $fila_destino->nombre, the name of the model to charge, but when i call the function loggin of tabla temp (the second line of the code), it's always charge the first model (the bug occurs when the $fila_destino->nombre it's different than the first time it's called.
An example. i need to load in the first time the model "model1" and load in 'tabla_temp'
and the second time to "model2" and load to in "tabla_temp" but, the second time the model "model2" doesn't load on 'tabla_temp' besides 'tabla_temp' it's an instance of "model1".
[/quote]
Does your variable:
Code:
$fila_destino->nombre
contain a valid model name?
Is it capitalized as in 'Model1' or 'Model2' which I think are the class names of your model classes.
#3

[eluser]Unknown[/eluser]
Yes, the variable
Code:
$fila_destino->nombre
always give me a valid model name, indeed when i used with the other models, works , the problem is just when i called the funcion 2 times and the second time the variable.
Code:
$fila_destino->nombre
give me. another string (a valid model name).
i tried with
Code:
$this->tabla_temp=null;
and
Code:
unset($this->tabla_temp);
but it didn't work. throw me an error




Theme © iAndrew 2016 - Forum software by © MyBB