gpt4 book ai didi

php - 调用模型文件中非对象的成员函数 num_rows()

转载 作者:行者123 更新时间:2023-11-30 23:56:44 25 4
gpt4 key购买 nike

这是我在模型中的代码..

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com