簡體   English   中英

在CodeIgniter Activerecord中執行WHERE!=

[英]Perform WHERE != in CodeIgniter Activerecord

如何在CodeIgniter Activerecord中執行WHERE column != 100001 抱歉,但是我找不到任何相關信息。

我的查詢是

$this->db->select('friend, username, fullname, profile_pic')
                        ->from('friends')
                        ->join('user_info', 'user_info.id = friend')
                        ->where('user', $my->id)
                        ->where('status', '1')
                        ->get()->result_object();

我想添加->where('friend' != 10001)嗎?

永遠記住第二個參數是值:

->where('friends.friend !=', 10001)

是的,這在活動記錄手冊中有詳細記錄

它在“ Custom key/value method: ->where()方法的一部分。

我知道兩種方法,首先在變量中聲明語法。這是代碼

$where = "user='".$my->id."' AND status='1' AND friend !=10001";

$this->db->where($where);

或使用這個

$this->db->where('friend !=', 10001);

暫無
暫無

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

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