My model class:
<?php class Permissions extends CI_Model {
private $userID = '';
private $permissions = '';
function __construct($userID)
{
// Call the Model constructor
parent::__construct();
$this->userID = $userID;
....
}
function __construct()
{.....}
?>
and I want to load this model with a parameter, apparently I could not do it.
Without a parameter I can load parameterless constructor by this way:
$this->load->model('Permissions');
My first question: is loading a model with a parameter nonsense?
Second one: if it is doable, how can I do that?
Thanks in advance.
You could take a look at this forum thread: http://codeigniter.com/forums/viewthread/115681/
But I can’t see why would you want to give a userid as a parameter in a way for permission checking? Guessing you use sessions to save userdata, write the userid in the session and call this in the Model with $this->session->userdata(‘user_id’).
Happy coding!