在CakePHP 3.0中对ResultSet执行类似get()的操作

时间:2015-08-08 14:29:51

标签: php cakephp find cakephp-3.0

$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) 

有可能吗?

0 个答案:

没有答案