我想通过codeignitor获取mysql代码的以下结果。 它为tbl_user_unavailability表中提供的时间帧提供非等于id(tbl_user)
MySql代码
SELECT tbl_user.id
FROM tbl_user
INNER JOIN tbl_user_unavailability
on tbl_user_unavailability.user_id <> tbl_user.id
WHERE '2018-02-02' BETWEEN begin_date AND end_date;
结果
22
25
find the mysql code result screenshot here
通过codeignitor获得此结果,我使用了以下代码
控制器代码
公共功能测试(){
$current_date = '2018-02-02';
$available_users = $this->mod_users->test_test($current_date);
$data['available_users'] = $available_users;
//to test the result array
//var_dump($available_users);die();
$data['related_view']='user_unavailable_new';
$this->load->view('template', $data);
}
型号代码
public function test_test($ current_date){
$this->load->database();
$this->db->select('*');
$this->db->join('tbl_user_unavailability', 'tbl_user_unavailability.user_id <> tbl_user.id','inner');
$this->db->where("'$current_date' BETWEEN 'tbl_user_unavailability.begin_date' AND 'tbl_user_unavailability.end_date'");
$query = $this->db->get($this->table);
return $query->result_array();
}
结果
not showing anything
I have tested it with var_dump($available_users);die();
It shows empty array