Welcome Guest, Not a member yet? Register   Sign In
Feature Suggestions? (Variables in Model's)
#1

[eluser]beneck[/eluser]
I tried to search, but I couldn't find a similar thread.

Is there a "feature suggestion" for CI? I know that EL is looking for someone to take it over, but they say that it's status quo in the mean time.

The reason I ask is because I would like to suggest that the model load functionality be able to take a 3rd parameter..an array.. for the construct model.

Here is an example of what I would like to see CI do in the future.....

Code:
$construct_vars = array("username", "password");

$this->load->model('user_model', 'user', $construct_vars);

The idea would be that the array is broken out and the item at index 0 becomes the first argument in the __construct() function, and the item and index 1 becomes the second argument (and so on and so forth) so that you can build more powerful model.

As of right now, the only two options I see are to

1) Look and see if any constructor arguments were passed, if not, then create an empty object. Then after I load the model, I simply create a new instance of it with the constructors I need.

OR

2) make a special construct function so that after the model is loaded, I call my own constructor such as $this->user->_construct('username', 'password');.

Either way seems like an extra step
#2

[eluser]beneck[/eluser]
I guess I could modify the core files to accept this functionality, but I prefer to leave the core files alone so that future updates (if there are any) don't break anything.
#3

[eluser]sv3tli0[/eluser]
You can instead make one function init($params){}
Which will load your vars to the model Smile

Code:
$construct_vars = array("username", "password");

$this->load->model('user_model', 'user');
$this->user->init($construct_vars);

Don't forget that most of the models are extending CI_Model and setting constructive variables may be a problem Smile




Theme © iAndrew 2016 - Forum software by © MyBB