Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use where clause and inner join in Cakephp 3 ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.23k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: