dongwei3866 2015-03-26 08:37
浏览 56
已采纳

如何在codeigniter中的select语句中使用between子句

I'm trying to get data from database by taking one data row from one table and use those values as where condition. and then i tried pass json string to controller class. but i'm unable to reach this. how should i write this code This is code i used to get data.

 $query = $this->db->query("SELECT * FROM todaywork WHERE idEmployee = $user ");

        if ($query->num_rows() > 0)
        {
           $row = $query->row(); 

               $from = $row->T_frange;
               $to = $row->T_trange;
               $note = $row->T_note;
        }     
               $this->db->select("cus.idCustomer,cus.C_name,f.F_itemname,ctr.*");
                //$whereCondition = array('cus.idCustomer' => $_POST['custId']);
                $this->db->where('C_trnoofarr BETWEEN {$from} AND {$to}');
                //filter where
                $this->db->from('customer cus');
                $this->db->join('contracts AS ctr', 'cus.idCustomer = ctr.idCustomer', 'INNER');
                $this->db->join('facility AS f','ctr.idContracts = f.idContracts','INNER');
                $query = $this->db->get();

                return $query->result();

    }
  • 写回答

2条回答 默认 最新

  • doulu8537 2015-03-26 08:50
    关注

    Use this for between

    $this->db->where('C_trnoofarr >', $from);
    $this->db->where('C_trnoofarr <', $to);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制