我的分页不起作用。我正在使用codeigniter 2.1.4。我不明白当我运行这个问题时会出现什么问题,比如"未定义的属性:Crud :: $ limit"。 Plz帮助
这是我的控制器:
public function index($offset = 0)
{
$data['title'] = "Basic CRUD Function With Codeigniter";
//echo "Done";
$offset = $this->uri->segment(3);
$records = $this->crud_mdl->get_paged_list($this->limit, $offset)->result();
$this->load->library('pagination');
$config['base_url'] = base_url().'/index/';
$config['total_rows'] = $this->crud_mdl->count_all();
$config['per_page'] = $this->limit;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
//$records = $this->crud_mdl->get_all_data();
$this->load->library('table');
$this->table->set_heading('ID','NAME','E-MAIL','PHONE','ACTION');
foreach ($records as $record) {
$this->table->add_row($record->id, $record->name, $record->email, $record->phone,
anchor('crud/viewCrud/'.$record->id,'view').' '.anchor('crud/editCrud/'.$record->id,'edit').' '.anchor('crud/delete/'.$record->id,'delete')
);
}
$data['table'] = $this->table->generate();
$this->load->view('crudlist',$data);
}
这是我的模特:
public function count_all()
{
return $this->db->count_all('test');
}
public function get_paged_list($limit = 4, $offset = 0)
{
return $this->db->get('test', $limit, $offset);
}
答案 0 :(得分:1)
在Crud类中声明和定义变量$ limit吗? 尝试将此添加到高级控制器Crud。