请帮助我,我想将简单的SQL语句转换为Codeigniter
date($fromDate) BETWEEN vehicle_register.start_dt AND vehicle_register.end_dt
答案 0 :(得分:2)
尝试使用Method chaining
,
$this->db->select('*');
$this->db->from('yourTableName');
$this->db->where('date('.$fromDate.') >=', 'vehicle_register.start_dt');
// >= will get conditional date too so please keep it as your reqirement
$this->db->where('date('.$fromDate.') <=', 'vehicle_register.end_dt');
$query= $this->db->get();
if($query->num_rows() > 0){
//return $query->result();//according to your need
}else{
//return array();//according to your need
}