Consider, we have users and the users have accounts (one-to-many). Now I am completely stuck at the following problem: we provide a $query
and want to return all users:
- whose
fullname LIKE %$query%
OR - whose
email LIKE %$query%
OR - who have accounts, of which
organisation LIKE %$query%
I already tried joins and containable behavior but no success. With joins we could achieve this, but the problem is, the data is not structured in the cake way (we get only one row pro match even if same user occurs multiple times). Resorting the data will not be OK because this controller must be very fast.
Help!