我需要格式化以下蛋糕 php 连接,而不必在我的控制器中运行丑陋的 php 脚本。
这是我的 cakephp 加入
$this->Type->find('all' , array(
'conditions' => array( 'Type.id' => '2' ),
'joins' => array(
array(
'table' => 'subtypes',
'alias' => 'Subtype',
'conditions' => 'Subtype.tid = Type.id'
)
)
));
这是我得到的输出
Array
(
[0] => Array
(
[Type] => Array
(
[id] => 4
[name] => Clay
[handle] => CL
[description] =>
)
[Subtype] => Array
(
[id] => 11
[tid] => 4
[name] => Water Based
)
)
[1] => Array
(
[Type] => Array
(
[id] => 4
[name] => Clay
[handle] => CL
[description] =>
)
[Subtype] => Array
(
[id] => 12
[tid] => 4
[name] => Oil Based
)
)
)
这是我想要的输出
Array
(
[0] => Array
(
[Type] => Array
(
[id] => 4
[name] => Clay
[handle] => CL
[description] =>
)
[Subtype] => Array(
[0] => Array(
[id] => 11
[tid] => 4
[name] => Water Based
)
[1] =>Array
(
[id] => 12
[tid] => 4
[name] => Oil Based
)
)
)
)
我怎样才能做到这一点?
非常感谢^^