php – Codeigniter URI段返回布尔值
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – Codeigniter URI段返回布尔值,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1723字,纯文字阅读大概需要3分钟。
内容图文
我是Codeigniter的新手,我正在尝试使用分页.我的问题是出乎意料的,因为我的分页代码完美地工作,除了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(' ',$str_links);
/* paginationEnd */
其中SEARCHHOTELS常数为
define('SEARCHHOTELS', SITE_URL.'search/hotels/');
在我的代码中:$this-> uri-> segment(3)总是返回布尔值.
当我点击我的分页时,URL值会改变:
http://localhost/holidays/search/hotels/
至:
http://localhost/holidays/search/hotels/1 (or 2,3,4)
URI段没有设置我的$this-> db-get查询中的值的偏移量. #
任何帮助将不胜感激.
解决方法:
如果有人遇到这种麻烦,我想分享我在两天内找到的解决方案.
我的页面流程是:
search-controller->search-view->alot-of-ajax-request->find-all-hotels();
用于分页的uri段仅在控制器中工作,即它将在加载视图之前获取段.
如果你想在通过ajax调用的函数中获取uri段.
它将无法工作,只能获取控制器和方法的2个段,之后将跳过所有方法.
希望这会帮助其他人
内容总结
以上是互联网集市为您收集整理的php – Codeigniter URI段返回布尔值全部内容,希望文章能够帮你解决php – Codeigniter URI段返回布尔值所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。