How to use where clause and inner joins?
This is the way to use where clause and inner joins in Cakephp 3
Use matching
if its cakephp 3.0.x.
Use innerJoinWith()
if its cakephp 3.1.x
For example:
return $this->Product->find()
->matching('ProductReview', function ($q) {
return $q->where(['ProductReview.del_yn' => 'n']);
})
->contain(['ProductReview', 'Users'])
->where(['Product.product_code' => $productCode])
->group('Product.id')
->toArray();
Thanks for reading the blog.
0 Comment(s)