在下面的代码中,我得到了第三个if-else语句的空数组。我想要的是从用户那里得到一系列的日期并相应地显示表中的数据。我的第一个if-else语句返回所需结果,但第二个语句返回空数组。在codeigniter项目中获取一个空数组
控制器:
public function bookings()
{
if($this->userlib->isLoggedIn())
{
if($this->userlib->isAdmin())
{
$this->load->view('admin_search_booking');
$date_posted_from = $this->input->post('date_posted_from');
$date_posted_till = $this->input->post('date_posted_till');
$date_posted_on = $this->input->post('date_posted_on');
if(is_null($date_posted_from) && is_null($date_posted_till) && is_null($date_posted_on))
{
$total_trails = $this->admin_panel_model->total_trail();
var_dump($total_trails);
}
elseif(!is_null($date_posted_on))
{
$total_trails = $this->admin_panel_model->filter_on_date($date_posted_on);
var_dump($total_trails);
}
elseif(!is_null($date_posted_from) && !is_null($date_posted_till))
{
$total_trails = $this->admin_panel_model->filter_by_date($date_posted_from, $date_posted_till);
var_dump($total_trails);
}
}
}
else
{
echo "User not Logged In";
}
}
型号filter_by_date
: -
public function filter_by_date($date_posted_from, $date_posted_till)
{
$query = $this->db->select('*')
->where('date >=', $date_posted_from)
->where('date <=', $date_posted_till)
->get($this->search);
return $query->result();
}
isLoggedIn: -
public function isLoggedIn()
{
if($this->ci->session->email)
return true;
else
return false;
}
尝试'echo'您的查询,并检查它的Sql –
查询中工作是工作的罚款,检查,居然当我删除第一ifelse,其他ifelse工作得很好。 –
发表你的'isLoggedIn'功能 –