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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器