dongxue9997 2015-01-11 14:17
浏览 83
已采纳

无法加载codeigniter分页库

I am working on the codeigniter as a beginner,, and got this problem.. I cannotload the Pagination Library...

Here is the code

<?php

/**
* 
*/
class Site extends CI_Controller
{
public function index() {

    if($this->load->library('pagination')) {
        echo "load success";
    }
    else {
        echo "load failed";
    }

    $config['base_url'] = 'http://localhost/ci_pagination/index.php/site/index';
    $config['total_rows'] = $this->db->get('data')->num_rows();
    $config['per_page'] = 10;
    $config['num_links'] = 20;

    $this->pagination->initialize($config);
    echo $this->pagination->create_links();

    $data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));

    $this->load->view('site_view', $data);
}

}

?>

I even tried autoloading pagination library.. But still it is echoing 'Load Failed' . CAN SOMEBODY HELP ME???????? plzzzzzz

  • 写回答

1条回答 默认 最新

  • dtpxi88884 2015-01-11 16:56
    关注

    You need to check your code, load function does not return boolean value (it returns NULL or error), therefore your if() statement is always false, in fact you can check in CodeIgniter logs after you turn on log_threshold config value to 2 - DEBUG.

    It looks like this:

    DEBUG - 2015-01-11 16:51:11 --> Pagination Class Initialized
    

    testing code I am working with:

    public function pagination() {
        var_dump( $this->load->library('pagination') );
    }
    

    Further more you want this line in your view file instead of controller itself.

    echo $this->pagination->create_links();
    

    Please do your homework before asking here next time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决