【发布时间】:2017-05-29 05:38:50
【问题描述】:
我有一个有品牌的产品。产品表中的brand_id。
品牌拥有一系列图片。
图像在表中有 id、product_id 和路径。
在产品索引中,您会从下面获得具有关联品牌数据的实体。你不能比我想要的更深入:
$product->brands[0]['image_id'];
为了获得路径,我希望能够像这样:
$product->brand->image['path'];
目前产品索引的内容如下:
$this->paginate = [
'contain' => ['Brands']
];
$products = $this->paginate($this->Products);
$this->set(compact('products'));
$this->set('_serialize', ['products']);
那么我如何处理“子查询”或其他东西来获取图像表数据(产品的二级关联,通过品牌)
我该怎么做?
【问题讨论】:
标签: php cakephp cakephp-3.0