【发布时间】:2016-03-07 01:37:19
【问题描述】:
我正在使用 CodeIgniter,但在使用 results() 方法从表中获取所有行时,我无法让 where() 选择方法工作。
这是我的模型:
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() 一起使用,但它只返回一行,因此不适合我的情况。
【问题讨论】:
标签: php mysql codeigniter model rows