Welcome Guest, Not a member yet? Register   Sign In
Trouble passing results from the model to the controller
#2

[eluser]Pascal Kriete[/eluser]
Yep, $query is not defined in the controller. It's only available in the scope of the function that you defined it in.

The obvious solutions would be:
1 - move the if statement to the model.
2 - return the query object instead of the results.

I usually use a variation of 1. I check for results in the model, but keep the rest of the logic in the controller by returning false to indicate no results.
Code:
return ($query->num_rows() > 0) ? $query->row() : FALSE;

Then in the controller you run a boolean check:
Code:
if ( ! $result)
{
    die("whatever");
}
//...

Welcome to CodeIgniter.


Messages In This Thread
Trouble passing results from the model to the controller - by El Forum - 10-21-2008, 04:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB