将大数据发送到CodeIgniter中的视图

时间:2015-10-04 11:36:54

标签: php codeigniter

我有一种情况,我必须向视图发送大量数据,我将从模型中返回。

这样的事情:

$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 );

正如你所看到的那样,它很快就变得太复杂了。

还有另一种方法吗?

0 个答案:

没有答案