|
本帖最后由 小蜗牛 于 2011-10-15 13:17 编辑
发现的问题$this->input->get('per_page')是空,为什么呢?请高手解释。
控制器方法
public function search()
{
$data['province'] = trim($this->input->get('province',true));
$data['city'] = trim($this->input->get('city',true));
$config['base_url'] = site_url("admin/city/search?province=".$data['province']."&city=".$data['city']);
$config['total_rows'] = $this->city->getSearchCount($data);
$config['per_page'] = 10;
$config['page_query_string'] = TRUE;
$this->pagination->initialize($config);
$data['cityList']=$this->city->getCity();
$data['list']=$this->city->getSearchList($data,$config['per_page'],$this->input->get('per_page'));
$data['pagination']=$this->pagination->create_links();
$this->load->view('admin/city_view',$data);
}
模型方法 模型的方法没有问题
public function getSearchList($data,$offset,$num)
{
$this->db->select('*');
if($data['city']>0){
$city = $this->getOne($data['city']);
$this->db->where('lft >=',$city['lft']);
$this->db->where('rgt <=',$city['rgt']);
}elseif($data['province']>0){
$province = $this->getOne($data['province']);
$this->db->where('lft >=',$province['lft']);
$this->db->where('rgt <=',$province['rgt']);
}
$this->db->order_by("lft", "asc");
$query=$this->db->get('v_city',$offset,$num);
if ($query->num_rows()>0){
return $query->result_array();
}
}
|
|