Loading model from variable? |
[eluser]debow[/eluser]
Is there a way to load a model from variable and call it throughout the controller. IE: controller/??.php Code: var $data = array( The reason being is I have controllers I can copy/paste and the only different is the table they are calling and their name so instead of having to change the the model name thats used many times in the controller I want to just change it in one location on each controller. Also want to call the model in this way as well. Code: $results = $this->$model->search($limit, $offset, $sort_by, $sort_order); Thanks
[eluser]InsiteFX[/eluser]
Code: $this->load->model($model) //This doesnt work...is there a way around it. InsiteFX
[eluser]toopay[/eluser]
Based by your ilustration... Code: var $data = array(
[eluser]toopay[/eluser]
@wiredesignz You're right about class var, i think both insiteFX and i didn't aware of that, especially for someone which reply this thread while drink a beer(thats me). It should be '$this->varname' not '$varname'. But he did clearly put this request too.. [quote author="debow" date="1302943535"] ... Also want to call the model in this way as well. Code: $results = $this->$model->search($limit, $offset, $sort_by, $sort_order); and then now, after clearing about class var, it seems you slightly slipped too, in your solution logics... [quote author="wiredesignz" date="1302959405"]@InsiteFX and toopay: The array is obviously a class variable. Code: var $data = array( based by above lines, then it will be running into this way... Code: $this->load->model($this->data['model']); @debow Code: //...some class var....
[eluser]InsiteFX[/eluser]
Thanks wiredesignz, I had a wicked head ache last night! Should have gone to bed LOL! InsiteFX
[eluser]debow[/eluser]
Thanks toopay, that worked and its much eaiser to reuse my controllers from one to the other. |
Welcome Guest, Not a member yet? Register Sign In |