CakePHP 3.0 how to contain a left outer join -
suppose candidates
has 1 field named ratings
. association optional.
i want candidates
having rating other 0 or no rating @ , contain ratings in result.
i managed right query first part coding left outer join this:
$this->candidates ->find('all') ->leftjoin( ['ratings' => 'ratings'], [ 'ratings.candidate_id = candidates.id', 'ratings.rating = 0', ], ['ratings.rating' => 'integer']) ->where('ratings.id null');
however failed rating contained within result. how can done?
did add contain()
query?
$this->candidates ->find('all') ->contain('ratings') ->leftjoin( ['ratings' => 'ratings'], [ 'ratings.candidate_id = candidates.id', 'ratings.rating = 0', ], ['ratings.rating' => 'integer']) ->where('ratings.id null');
Comments
Post a Comment