$id = 1;
$product = $this->Products->get($id);
$offers = $this->Products->Offers->find()->where(['Offers.product_id' => $id]);
$offers
将包含两种行。一个type
a
指向$offers
type
的b
中的另一行字段offer_id
。
这就是为什么我需要一个类似Model->get()
的方法,以便我可以使用结果集的主键找到一个项目。
简而言之,我需要通过传递id从结果集中获取结果。 比如做:
$offers->getResultByPrimaryKey($offer_id)
有可能吗?