Codeigniter URI段返回布尔值

Fai*_*wan 4 php pagination codeigniter

我是Codeigniter的新手,我正在尝试使用pagination.我的问题是出乎意料的,因为我的分页代码完美地工作,除了URI段总是作为布尔值返回.我的代码是:

/* pagination */
$this->load->library('pagination');
$destination = $data['destination'];

$config = array();
$config["base_url"] = SEARCHHOTELS.$this->uri->segment(3);

$total_row = $this->db->get('hotel')->num_rows();
$config["total_rows"] = $total_row;
$config["per_page"] = 30;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = '<a class="active">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$str_links = $this->pagination->create_links();


$this->db->select('*');
if(!empty($data['destination'])){
  $destination = $data['destination'];
  $this->db->like('name',$destination);
  $this->db->or_like('regionName',$destination);
}
$hSearch['records'] = $this->db->get('hotel',$config['per_page'],$this->uri->segment(3))->result_array();
$hSearch["links"] = explode('&nbsp;',$str_links);
/* paginationEnd */
Run Code Online (Sandbox Code Playgroud)

其中SEARCHHOTELS常数为

define('SEARCHHOTELS', SITE_URL.'search/hotels/');
Run Code Online (Sandbox Code Playgroud)

在我的代码中:$this->uri->segment(3)始终返回布尔值.

当我点击我的分页时,URL值会改变:

http://localhost/holidays/search/hotels/ 
Run Code Online (Sandbox Code Playgroud)

至:

http://localhost/holidays/search/hotels/1 (or 2,3,4) 
Run Code Online (Sandbox Code Playgroud)

URI段未设置偏移我的$this->db-get查询中的值.#

任何帮助将不胜感激.

Fai*_*wan 5

如果有人遇到这种麻烦,我想分享我在两天内找到的解决方案.

我的页面流程是:

search-controller->search-view->alot-of-ajax-request->find-all-hotels();
Run Code Online (Sandbox Code Playgroud)

分页的uri段仅在控制器中工作,即它将在加载视图之前获取段.

如果你想在通过ajax调用的函数中获取uri段.

它将无法工作,只能获取控制器和方法的2个段,之后将跳过所有方法.

希望这会帮助其他人