public function get_priority($priority_id = "") {
if ($priority_id == "") {
$qry = $this->db->get("tm_priority");
} else {
$qry = $this->db->query("SELECT * FROM tm_priority WHERE nt_id = {$priority_id}");
echo $this->db->last_query();
}
print_r($qry->result());
}
在我的上面的模型函数中,我回显了last_query()以进行调试,它给了我以下结果
SELECT * FROM tm_priority WHERE nt_id = 1
当我将此查询直接运行到我的mysqlyog中时,它工作正常。
那么还有什么可能是下面错误的原因
Fatal error: Call to a member function result() on a non-object in /home/staging/erp/application/models/tasks/task_model.php on line 341
答案 0 :(得分:0)
在输出之前,您应该尝试检查返回的行数:
if($qry->num_rows() > 0){
print_r($qry->result());
}