Welcome Guest, Not a member yet? Register   Sign In
how to pass argument to model constructor while loading a model
#2

[eluser]Evil Wizard[/eluser]
A library can accept __constructor parameters but the model doesn't see to. The alternative is to create an initialise() method that will accept your construct params.
Code:
class user_model extends model {
    public function __construct()
    {
        parent::__construct();
    }
    public function initialise($param1, $param2=NULL)
    {
        $this->param1 = $param1;
    }
}
then
Code:
$this->load->model('user_model');
$this->user_model->initialise('param1', 'param2');


Messages In This Thread
how to pass argument to model constructor while loading a model - by El Forum - 05-27-2009, 05:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB