$ categ = $ this-> FreeadsCategory-> bindModel(array('hasMany'=> array('subcategory'=> array('foreignKey'=>'category_id','order'=> ;'id ASC'))));
$ data = $ this-> FreeadsCategory-> findById($ i); $ this-> set(“datas”,$ data);
阵 ( [FreeadsCategory] =>排列 ( [id] => 1 [uuid] => 51512434-e4c4-441b-b90e-16f8732d5573 [category] =>汽车 [status] =>活性 )
[Subcategory] => Array
(
[0] => Array
(
[id] => 1
[uuid] => 4ea15f22-adf0-4020-b35d1-052ff9ff9a27
[category_id] => 1
[subcategory] => Cars/Cabs/Jeeps
[status] => Active
)
[1] => Array
(
[id] => 5
[uuid] => 51cec363-e7ac-4095-a86b-0ccdf260d1b4
[category_id] => 1
[subcategory] => Buses/Lorries
[status] => Active
)
)
答案 0 :(得分:0)
您不会在视图中获取违反MVC模式的数据。从技术上讲,有一些方法可以做到,但这是完全错误的,你最终会得到无法解决的垃圾代码。
我真的建议你先由reading about the MVC design pattern开始,然后先the CakePHP blog tutorial来了解CakePHP的工作原理。