Welcome Guest, Not a member yet? Register   Sign In
Best way to pass a couple of variables from a Controller to a Model?
#1

[eluser]brucebat[/eluser]
I have some variables :

$completedstaffrows and $completedeventrows that I need to control a for loop.

I was thinking about creating a class with just attributes and passing it to the model, but how does one pass it. I tried passing it through the function call from my controller and in the load model function but not luck.

I guess I could use a session but Is that really the best way?

Thanks
#2

[eluser]ccschmitz[/eluser]
Is there a reason you don't want to pass them as parameters to your model methods? i.e. do something like this in your controller:

Code:
$this->load->model('staff_model');
$this->staff_model->update_staff_events($completedstaffrows, $completedeventrows);

Then just have your model accept these params:

Code:
function update_staff_events($completedstaffrows, $completedeventrows)
{
    // do stuff with your vars...
}
#3

[eluser]toopay[/eluser]
Unless you process that variable in different http request, you doesn't need to use session.




Theme © iAndrew 2016 - Forum software by © MyBB