Reputation: 36307
I have a codeigniter constructor that begins like:
public function __construct($login, $pass)
I'm trying to pass parameters to it in my controller like so:
$params = array(1=>'xxx',2 =>'yyy');
$this->load->library('my_library',$params);
but I'm getting:
Message: Missing argument 2 for my_library::__construct(),
How can I fix this?
Upvotes: 1
Views: 2513
Reputation: 255005
CI doesn't work that way. The constructor should accept a single parameter like
public function __construct($param)
{
// access $param['login'] and $param['pass']
}
and invoke it like
$this->load->library('my_library', array(
'login' => 'xxx',
'pass' => 'yyy',
));
which is an array of your data
http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
Upvotes: 5