如何使用MySQL的Cakephp多维数组加入?

时间:2013-07-06 04:30:12

标签: php mysql cakephp

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

Cakephp如何返回多维数组?

例如下面的内容:

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

请记住我正在创建一个自定义框架而不使用Cakephp!

我可以查看Cakephp核心,但想在

之前与其他人核实

1 个答案:

答案 0 :(得分: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

提供的非常有用的文档

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

如果我可以帮助你,请告诉我。