我希望能够将SpecificationCategory.name分组为父类别和作为子项的规范,以便在数组中不会重复使用SpecificationCategory.name。
有没有办法在Cake中做到这一点?
Array
(
[0] => Array
(
[Specification] => Array
(
[id] => 15
[name] => AMD Phenom
[specification_category_id] => 1
[subsubcategory_id] => 1
[created] => 2012-10-16 08:18:27
[modified] => 2012-10-16 08:18:27
)
[SpecificationCategory] => Array
(
[id] => 1
[name] => Processor Type
[created] => 2012-10-15 13:50:03
[modified] => 2012-10-15 13:50:03
)
[Subsubcategory] => Array
(
[id] => 1
[name] => Laptops
[subcategory_id] => 1
[created] => 2012-06-24 02:23:40
[modified] => 2012-06-24 02:23:40
)
)
[1] => Array
(
[Specification] => Array
(
[id] => 12
[name] => AMD E350
[specification_category_id] => 1
[subsubcategory_id] => 1
[created] => 2012-10-16 08:18:02
[modified] => 2012-10-16 08:18:02
)
[SpecificationCategory] => Array
(
[id] => 1
[name] => Processor Type
[created] => 2012-10-15 13:50:03
[modified] => 2012-10-15 13:50:03
)
[Subsubcategory] => Array
(
[id] => 1
[name] => Laptops
[subcategory_id] => 1
[created] => 2012-06-24 02:23:40
[modified] => 2012-06-24 02:23:40
)
)
)
答案 0 :(得分:0)
如果您只是想通过SpecificationCategory获取列表,我只需从该模型中进行查找,该数组将列出每个类别下的所有规范。这假定规范有多个SpecificationCategory。