-1

因为有很多或有很多通过关系,

Cakephp如何返回多维数组?

例如如下所示:

array(
0 => array("CatOne" => array("One" => "Two"), "CatOneOne" => "Oneone"),
1 => array("CatTwo" => "Two"),
2 => array("CatThree" => "Three")
)

请记住,我正在创建我的自定义框架,而不是使用 Cakephp!

我可以看一下 Cakephp 核心,但想先与其他人核实一下

4

1 回答 1

1

据我了解您的问题,我希望看到输出数组有很多关系,例如

//Sample results from a $this->User->find() call.

Array
(
    [User] => Array
        (
            [id] => 121
            [name] => Gwoo the Kungwoo
            [created] => 2007-05-01 10:31:01
        )
    [Comment] => Array
        (
            [0] => Array
                (
                    [id] => 123
                    [user_id] => 121
                    [title] => On Gwoo the Kungwoo
                    [body] => The Kungwooness is not so Gwooish
                    [created] => 2006-05-01 10:31:01
                )
            [1] => Array
                (
                    [id] => 124
                    [user_id] => 121
                    [title] => More on Gwoo
                    [body] => But what of the ‘Nut?
                    [created] => 2006-05-01 10:41:01
                )
        )
)

你也可以参考CakePHP.org提供的非常有用的文档

它还定义了与模型关系的详细工作。

让我知道我是否可以为您提供更多帮助。

于 2013-07-06T04:45:27.077 回答