足夠長的時間我一直在使用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