当我尝试添加分页链接时,出现不支持的操作数类型错误
这是我的代码
模型
public function getCategory($limit,$offset){
$this->db->select("*");
$this->db->from("tbl_category");
$this->db->limit($limit,$offset);
$row = $this->db->get()->result_array();
return $row;
}
public function num_rows(){
$this->db->select('*');
$this->db->from('tbl_category');
$row = $this->db->get()->result_array();
return $row;
}
控制器
public function category($script="list",$id=""){
$data['script'] = $script;
if($script == 'list'){
$config = [
'base_url' => base_url('http://localhost/training/admin/'),
'per_page' => 2,
'total_rows' => $this->admin_model->num_rows(),
];
$this->pagination->initialize($config);
$rows = $this->admin_model->getCategory($config['per_page'], $this->uri->segment(3));
$data['rows'] = $rows;
}
在我的视图文件中,我这样做是为了获取链接
<?php $this->pagination->create_links(); ?>
我得到的错误如下
遇到未捕获的异常类型:错误
消息:不支持的操作数类型
文件名:C:\xampp\htdocs\training\system\libraries\Pagination.php
行号:412
回溯:
文件:C:\xampp\htdocs\training\application\views\category.php 行:101 功能:create_links
文件:C:\xampp\htdocs\training\application\controllers\Admin.php 行:150 功能:查看
文件:C:\xampp\htdocs\training\index.php 行:315 功能:require_once
