我有一种情况,我必须向视图发送大量数据,我将从模型中返回。
这样的事情:
$modelData = array (
array (
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array (
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
.......
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
)
),
array (
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array (
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
.......
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
)
),
.......
.......,
array (
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array (
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
.......
array ( 'mykey1' => 'somevalue1', 'mykey2' => 'somevalue2', ........ 'mykeyn' => 'somevaluen' ),
)
)
);
$data ['title'] = 'title';
$data ['x'] = 'something';
$data ['modelData'] = $modelData;
$this->load->view ( 'myview', $data );
正如你所看到的那样,它很快就变得太复杂了。
还有另一种方法吗?