![](/img/trans.png)
[英]CodeIgniter - Ensuring activerecord where statement has a criteria
[英]Codeigniter activerecord OR select statement
我正在使用最新版本的codeigniter,並嘗試使用activerecord類編寫一個簡單的查詢,但無法弄清楚如何進行OR語句。 這是代碼:
function get_active_trades()
{
$query = $this->db->get_where('trades', array('trade_status !=' => 2));
return $query->result();
}
理想情況下,應該是trade_status!= 2或user_trade_status!= 2.但是,我似乎無法找到實現這一目標的方法。 我在幫助頁面上找到了以下內容,但似乎無法使其工作:
$this->db->or_where();
有關如何使用activerecord進行此操作的任何建議?
像這樣:
function get_active_trades() {
$this->db->where('trade_status <>', 2);
$this->db->or_where('user_trade_status <>', 2);
return $this->db->get('trades')->result();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.