我正在使用 codeigniter 我想通过如下查询来显示从数据库中获取的一些数据。
$this->db->where('sex !=', $iam);
$this->db->where('sex', $searching_for);
$this->db->where('Age >=' , $age_from);
$this->db->where('Age <=' , $age_to);
if($Province != 1){
$this->db->where('Province' , $Province);
}
$this->db->limit($limit, $start);
$query = $this->db->get("members");
return $query->result_array();
由$iam,$searching_for, $age, $age_to
用户提供,我使用会话数组从控制器文件传递它们。
$search_info=array(
'iam' => $this->input->post('iam'),
'searching_for' => $this->input->post('searching_for'),
'age_from' => $this->input->post('age_from'),
'age_to' => $this->input->post('age_to'),
'country' => $this->input->post('country'),
'Province' => $this->input->post('Province')
);
$this->session->set_userdata(array("search_info" => $search_info));
我的分页功能也在控制器文件中,就像这样
public function pagination(){
$this->load->library("pagination");
$config = array();
$config["base_url"] = base_url() . "controller_search/index";
$this->load->model('models_search');
$config["total_rows"] = $this->models_search->search();
$config["per_page"] = 1;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
//$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;3
//echo $this->uri->segment(3);
//echo ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;3;
$page = $this->uri->segment(3);
$data["search_result"] = $this->models_search->fetch_categories($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$data['error'] = '';
$this->load->view('home_header.php');
$this->load->view('search/search_result',$data);
}
但问题是,当我单击页码时它没有显示任何内容,我尝试评论查询中的所有 where 线索,然后它就可以工作了。
所以我认为错误在会话数组中,我尝试var_dump
了 session_all 所以它显示array(0){}
在这种情况下谁能帮助我?