0

In Cakephp 3, how to make has-many association follow inner join type for contain(). For matching(), i am getting duplicates and the result of association collection is not nested

aravind_s
  • 106
  • 8
  • You want to get data which at least one row of the associated table? If so you can put a where clause in which you can check the count from sub-query. This will behave like the inner join. Because as @ndm says "There is no such thing as INNER joined hasMany containments" – Aman Rawat May 05 '17 at 05:11

1 Answers1

2

There is no such thing as INNER joined hasMany containments, as the CakePHP ORM will use an additional query to retrieve containments of that type.

If you get duplicates when using matching(), then use distinct() or group(). If you need to retrieve associated records additionally to matching, then use contain() too, and add conditions for the containment if necessary.

See also

Community
  • 1
  • 1
ndm
  • 59,784
  • 9
  • 71
  • 110