在下面的代碼中,我得到了第三個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'功能 –