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 java输入输出异常
  • ¥15 三子连珠对弈小游戏制作
  • ¥15 C++扑克牌游戏的编程
  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅