fecshop中如何coll时获取关联数据库的数据

文档问题 · ganbugandong · 于 5年前 发布 · 1496 次阅读

例如 Product 表关联了 ProductReview, 在获取products的时候,是否能顺带获取每个product的reviews呢

  $filter = [
                'numPerPage'    => $this->numPerPage,
                'pageNum'        => $this->pageNum,
                'orderBy'        => $this->orderBy,
                'where'            => [
                    ['customer_id' => $customer_id]
                ],
                'asArray' => true,
            ];

            $customer_store_list = Yii::$service->customer->product->coll($filter);

看了Yii的文档,不确定能不能用Yii的书写一个get方法比如 getReviews() 来实现, 谢谢。

共收到 2 条回复
successgo#15年前 0 个赞

可以。

请查询一下 yii with 的用法

Fecmall#25年前 0 个赞

建议使用多次查询,如果多个产品可以使用in查询

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics