这段代码有什么问题,为什么它返回 num_rows == 0。
function validate()
{
$this->db->where('username', $this->input->post('username'));
$this->db->where('userpassword', md5($this->input->post('password')));
$query = $this->db->get('tbluser');
if($query->num_rows == 1)
{
return true;
}
}
这是我的数据库截图
还有我在 mysql 中执行的查询的屏幕截图
最佳答案
您忘记了()。应该be $query->num_rows()
if($query->num_rows() == 1)
{
return true;
}
它返回 0 的原因是 $query->num_rows
不存在(结果为 false 或 0)。
关于php - CodeIgniter 错误输出 num_rows == 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35884072/