1
我使用的是CodeIgniter,当使用results()
方法从表中提取所有行时,我无法使where()
选择方法起作用。CodeIgniter模型无法返回特定记录
这里是我的模型:
public function get_all_entries($id)
{
// Select row to be fetched
$this->db->where('id', $id);
$this->db->get('users');
// Execute the find query with provided data
$query = $this->db->get('users');
// Return an object with all the data
return $query->result();
}
它应该返回所有匹配的users
表$id
的说法,但相反,它只是取表中的所有记录,包括那些没有按行与提供的$id
参数不匹配。
我在做什么错在这里?我试过row()
方法,虽然它与where()
一起使用,但它只返回一行,所以它不适合我的情况。
我试过了,但是还有一个问题(如果ID是在表零与否),导致我觉得这也不是办法,现在我固定的问题,解决你提到的作品,谢谢。 –
很高兴它的工作。 –
您能否提出问题upvote?真的很感激。 –