如何在codeigniter中使用一个列检查两个值

如何在codeigniter中使用一个列检查两个值

问题描述:

I want to check two values with one Column of database in codeigniter. There is 'add_date' column in database I want to check values coming from $daterange variable with 'add_date' Column. The $daterange variable is split into array by using $array = explode(' ', $daterange);

Now I want to check the 'add_date' column with first index of $array and also with second index of $array. But the $where does not gives actual value.

public function get_reports() {
    if ($this - > input - > post()) { //If Any Values Posted
        if ($this - > input - > is_ajax_request()) { //If Request Generated From Ajax
            //Getting Posted Values
            $daterange = $this - > input - > post('daterange');
            $array = explode(' ', $daterange);
            $where = array(
                'add_date' > $array[0],
                'add_date' < $array[1]
            );

            $this - > data['sales'] = $this - > Common_model - > select_fields_where_like_join("add_sales", "*", '', $where);
            $this - > show('reports/sales_reports', $this - > data);
        }
    }
}

我想在codeigniter中使用一列数据库检查两个值。 数据库中有'add_date'列我要检查来自$ daterange变量的值和'add_date'列。 $ daterange变量通过使用 $ array = explode('',$ daterange); code> p>

分割成数组现在我想检查'add_date'列 第一个$ array索引以及$ array的第二个索引。 但$ where不给出实际值。 p>

  public function get_reports(){
 if($ this  - &gt; input  - &gt; post()){// 如果发布任何值
 if($ this  - &gt; input  - &gt; is_ajax_request()){//如果请求从Ajax生成
 //获取发布值
 $ daterange = $ this  - &gt; 输入 - &gt;  post('daterange'); 
 $ array = explode('',$ daterange); 
 $ where = array(
'add_date'&gt; $ array [0],
'add_date'&lt; $ array  [1] 
); 
 
 $ this  - &gt;  data ['sales'] = $ this  - &gt;  Common_model  - &gt;  select_fields_where_like_join(“add_sales”,“*”,“',$ where); 
 $ this  - &gt;  show('reports / sales_reports',$ this  - &gt; data); 
} 
} 
} 
  code>  pre> 
  div>

You should simply Replace this code

'add_date' > $array[0],
'add_date' < $array[1]

With this code. And I am Sure it will Works for you.

'add_date >'$array[0] ,'add_date <'$array[1]