簡體   English   中英

AND代碼點火器的活動記錄

[英]Active record for AND in code igniter

如何在codeigniter中的活動記錄中編寫此查詢。

 SELECT * FROM `post_ads` WHERE `dates` >= '2014-09-20' AND `dates` <= '2014-09-22' ORDER BY `dates` ASC

我嘗試了這段代碼但是給了一個空數組。

 $where = "DATE(dates) BETWEEN '2014-09-20' AND '2014-09-22'";
    $query = $this->db->where($where)->get('post_ads');
    return $query->result();

簡單地重復兩次,如下所示:

$this->db->select();
$this->db->from('post_ads');
$this->db->where('dates','2014-09-20');
$this->db->where('dates','2014-09-22');
$this->db->order_by('dates');

如果沒有數組,你可以嘗試在條件分開的地方; 創建AND操作。

      $this->db->where('dates >=', 2014-09-20);
      $this->db->where('dates <=', 2014-09-22);
      $this->db->order_by("dates", "asc");
       $query = $this->db->get('post_ads');
      return $query->result();

從codeigniter教程:我的查詢使用以下查詢:

$array = array('dates >=' => $to, 'dates <=' => $from); 
$this->db->where($array);
$this->db->order_by("dates", "asc"); 
$query = $this->db->get('post_ads');
return $query->result();

暫無
暫無

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

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