Welcome Guest, Not a member yet? Register   Sign In
User_Guide recommendations produce error
#1

[eluser]John_Betong_002[/eluser]
http://ellislab.com/codeigniter/user-gui...sults.html
Quote:The above function is an alias of result_object().

If you run queries that might not produce a result, you are encouraged to test the result first:

$query = $this->db->query("YOUR QUERY");

if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
echo $row->title;
echo $row->name;
echo $row->body;
}
}

Test script:
Code:
$query = $this->db->query("SELECT * FROM non_existent_table");

// exception thrown on following line
if ($query->num_rows() > 0)

// replacement that catches exception
if ($query && $query->num_rows() > 0)
I think the problem has arisen because 'development' error_reporting now set to E_ALL.
 
 
edit: changed 'production' to 'development'
 






Theme © iAndrew 2016 - Forum software by © MyBB