Codeigniter:其中查询不符合条件


codeigniter: where query in not condition

如果选择所有id =11的记录

 $this->db->select('title')->from('mytable')->where('id', $id)->limit(10, 20);
 $query = $this->db->get();

那么选择CodeIgniter样式中id != 11的所有记录的查询是什么?

将其添加到where的列部分,因此

$this->db->select('title')->from('mytable')->where('id !=', $id)->limit(10, 20);
$query = $this->db->get();

顺便说一句,一定要检查代码编写器手册,它和where()文档一起提到了这一点,这是你能找到的最好的文档之一。

这可能行得通:

$this->db->select('title')->from('mytable')->where('id !=', $id)->limit(10, 20);
 $query = $this->db->get();

这也是一个专业和干净的方式:)

$where(array('id !' => $id, 'qty >' => '10'));
        $this->db->select('title');
        $this->db->from('mytable');
        $this->db->where($where);
        $this->db->limit(10, 20);
        $query = $this->db->get();