【问题标题】:Undefined table data未定义的表数据
【发布时间】:2012-04-04 07:32:56
【问题描述】:

我将 CI 2.1.0 与 HMVC 一起使用。我将在视图部分实现分页。但我得到 'Undefined table data' 错误。它显示页码(1,2,3,..),但不显示记录。

我的代码是:

包含的分页库: $this->load->library('table');

控制器

$data['title'] = "Test Events";
$this->load->library('pagination');

$config['base_url'] = 'http://localhost/myproject/index.php/events/test/';
$config['total_rows'] = $this->eventModule->countRow();
$config['per_page'] = '3';

$this->pagination->initialize($config);
$config['records'] = objectsIntoArray($this->eventModule->get_record($config['per_page'], $this->uri->segment(3)));

$data['main_content'] = 'test';       
$this->load->view('event/template', $data); 

查看

<?php echo $this->table->generate('records'); ?>
<?php echo $this->pagination->create_links(); ?>  

感谢您的支持。

【问题讨论】:

  • 如果您希望有人帮助您接受您首先提出的问题的答案。
  • @safarov,这不是你想的那样。我做了,但没有看到任何变化。所以我试图弄清楚我的目录结构..无论如何谢谢你的时间。

标签: codeigniter


【解决方案1】:

我终于得到了解决方案。这是一个愚蠢的错误

$config['records'] = objectsIntoArray($this->eventModule->get_record($config['per_page'], $this->uri->segment(3)));

应该是 $data 而不是 $config

$data['records'] = objectsIntoArray($this->eventModule->get_record($config['per_page'], $this->uri->segment(3)));

【讨论】:

    猜你喜欢
    • 2014-08-24
    • 1970-01-01
    • 2017-04-07
    • 2013-05-26
    • 2019-06-08
    • 1970-01-01
    • 2017-05-08
    • 2018-01-01
    • 1970-01-01
    相关资源
    最近更新 更多