[eluser]Unknown[/eluser]
Has this issue ever been discussed?
From my Controller class, I tried to call a function in a model with
two parameters.
Model:
Code:
function some_function($a, $b)
{
$this->db->select('*');
$this->db->from('a_table');
return $this->db->get();
}
The problem is if I do something like this in my Controller class:
Controller:
Code:
$this->load->model('My_model');
if ($this->My_model->some_function($param1, $param2)->num_rows() > 0)
{
echo "data found.";
}
it will return this error: "Fatal error: Call to a member function num_rows() on a non-object".
It will be different if I make a variable to call the function first:
Controller:
Code:
$this->load->model('My_model');
$query = $this->My_model->some_function($param1, $param2);
if ($query->num_rows() > 0)
{
echo "data found.";
}
This should be no error.
So, I have to make a variabel
$query to represents the
$this->My_model->some_function($param1, $param2) first, then I can use
num_rows() on my Controller class.
Is there anybody ever got the same case?