足够长的时间我一直在使用codeignter,它的类真的很好,简单而有用。
我正在尝试在我的自定义php框架中将分页类集成到CI设置的/ base/system/libraries文件夹中,然后我成功地将Table类与PHP数据集成在一起以创建动态表。
这里我遇到了/base/system/libraries/Pagination.php中的$CI =& get_instance();
问题,它在controller.php中被实例化。 而它的抛出错误是因为我没有使用整个控制器,而只是它的类。
有没有我可以使用分页类,没有get_instance()的任何解决方案。需要使用codeigniter类的核心php
0
A
回答
0
1
$CI =& get_instance();
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
if ($CI->input->get($this->query_string_segment) != $base_page)
{
$this->cur_page = $CI->input->get($this->query_string_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
}
else
{
if ($CI->uri->segment($this->uri_segment) != $base_page)
{
$this->cur_page = $CI->uri->segment($this->uri_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
}
与
if(isset($_GET['cur_page'])){
$this->cur_page = $_GET['cur_page'];
}else{
$this->cur_page = 1;
}
&
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
$this->base_url = rtrim($this->base_url).'&'.$this->query_string_segment.'=';
}
else
{
$this->base_url = rtrim($this->base_url, '/') .'/';
}
删除此。
这样称呼它,
include_once(LIB_DIR.'/pagination.class.php');
$pagination = new Pagination();
$config['base_url'] = 'http://testme.com/stats.php?cur_page=';
$config['total_rows'] = 200;
$config['per_page'] = 20;
$pagination->initialize($config);
echo $pagination->create_links();
相关问题
- 1. 扩展CodeIgniter的核心类
- 2. Codeigniter扩展核心类
- 3. Codeigniter无法调用核心类
- 4. 扩展核心类Codeigniter - 404错误
- 5. Codeigniter核心类无法加载(Linux)
- 6. 需要启动使用核心服务的工作流程
- 7. jQuery定制核心:只使用你需要的东西
- 8. 需要了解拳击在核心java
- 9. 核心0.13.0.job.jar失踪,我需要它
- 10. 核心数据:为什么需要NSFetchedResultsControllerDelegate?
- 11. 我是否需要为OpenGL 3.3核心使用着色器?
- 12. 使用ruby核心库解析HTML? (即,不需要宝石)
- 13. 麻烦核心PHP中使用的htaccess
- 14. PHP需要使用需要xs的webservice:base64Binary
- 15. 需要资源的问题PHP Codeigniter
- 16. 我需要在Codeigniter中使用HTMLpurifier吗?
- 17. iPhone应用程序使用核心剧情(需要解决的问题)?
- 18. 我需要在我的应用程序中使用核心数据吗?
- 19. 引用ASP.NET核心类库
- 20. 从.net核心的核心类库中无法看到dbContext类
- 21. 重写核心类
- 22. Codeigniter 2.0无法扩展核心库
- 23. 如何在.NET核心应用程序中使用.NET核心类库?
- 24. 如何使用核心数据更新和删除需要记录的表格
- 25. 使用xilinx的divider核心
- 26. 由默认的Spark本地模式的核心数需要
- 27. 从核心CodeIgniter类继承时禁止调试日志?
- 28. CodeIgniter:核心/覆盖,缺少加载/加载器类
- 29. 类别及其核心类
- 30. EF核心循环参考ASP.NET核心用户类
你似乎有使用笨库倒挂的整个概念。你可以发布你想要做的一些代码吗? – 2012-01-17 05:59:46
如果这是你的_modus operandi_,那么最好使用Zend Framework。你是什么意思“我没有在任何地方使用控制器”?所以你只是在你的个人项目中使用CI的分页课程,而没有其余的框架? – 2012-01-17 06:14:32
@JosephSilber,是的,我知道它使用它的奇怪方式;-),但我只是包括类文件。并通过创建object.I使用它的函数。我使用CI的表类如下:'include_once(LIB_DIR。'/ Table .php'); $ table = new Table('default_template'); $ table-> set_heading($ dataHeader); $ table-> generate(); '等 – Debugger 2012-01-17 10:46:08