dousuie2222 2018-09-15 04:29
浏览 35
已采纳

如何在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);
        }
    }
}
  • 写回答

1条回答 默认 最新

  • douxi9245 2018-10-01 12:02
    关注

    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]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目