Welcome Guest, Not a member yet? Register   Sign In
Passing parameters to model constructor
#1

(This post was last modified: 08-19-2017, 04:17 AM by CINewb.)

Sorry, I know this has been covered before.  Some of the questions regarding this are quite old, and I wondered why this functionality hasn't been made available as standard?

It would be really useful to be able to pass arguments to a model's constructor, along the lines of:

PHP Code:
$this->load->model('some_model'$args); 

Then in the model have:

PHP Code:
public function __construct($args) {


I know I could make my own initialization method and do:

PHP Code:
$this->load->model('some_model');
$this->some_model->init($args); 

However I have some arguments that are required for the whole model to work, and if I forget to call init() things will get somewhat messy.
Reply


Messages In This Thread
Passing parameters to model constructor - by CINewb - 08-19-2017, 03:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB