这是我在模型中的代码..
function get_info($product_id)
{
$this->db->from('product');
$this->db->where('product_id',$product_id);
$query = $this->db->get();
if($query->num_rows()==1)
{
return $query->row();
}
关于 stackoverflow 的问题太多了,但我没有找到与场景相关的任何答案。那我做错了什么??
最佳答案
您的查询可能失败了。确保数据库调试开启并修改您的代码:
if ($query !== FALSE)
{
// Run your code
if ($query->num_rows() === 1)
{
return $query->row();
}
}
else
{
// Check error
echo 'Database Error(' . $this->db->_error_number() . ') - ' . $this->db->_error_message();
}
关于php - 调用模型文件中非对象的成员函数 num_rows(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27654328/