cant pass parameters from controller to a models constructor? |
[eluser]ajsie[/eluser]
cant you pass parameters from controller to a models constructor? or do i have to pass it after i have loaded the model to another method? $this->load->model('my_model'); $this->Contact_model('my name', 'my email'); so __construct() will ALWAYS be without parameters in CodeIgniter with other words?
[eluser]adamp1[/eluser]
You could create an initialise method? Code: $this->load->model('my_model'); Then just have a bool check in each that it has a valid name/email. OR if you really wanted to pass constructor paramters. Override the Loader.php class so you can pass in config values like the load library method.
[eluser]Zeeshan Rasool[/eluser]
[quote author="adamp1" date="1271072528"]You could create an initialise method? Code: $this->load->model('my_model'); Nice explanation ! You can also do this job with class variable of model. If you want to use a model on bases of some param then create that models object and assign it a value as parameter. i-e In controller's any function assign Code: $this->yourModel->class_variable = 1 Code: $this->class_variable Regards, Zeeshan
[eluser]lezeroq[/eluser]
Maybe someone is still interested in this issue. Another solution. |
Welcome Guest, Not a member yet? Register Sign In |