簡體   English   中英

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();

順便說一句,請務必閱讀codeigniter手冊,它在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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM