I want to make a query like this:
$meetings = $this->find()->matching(‘Tasks.Kanbans.KanbanItems.Tasks’, function ($q) {
return $q->where([ … ]);
})
->toList();
As you can see, I have “Tasks” twice in the path.
I only need the Meetings and the second Tasks Model in the result.
But $meeting->_matchingData only contains one Tasks Result.
The result for the second Tasks Model gets overridden by the first Tasks Model in the path.
I didn’t find a way to set an alias for one of the “Tasks”.
How can I set an alias or get the result in another way ?
I did this, but hoped for a better solution.
It gets very huge and ugly.
And it feels wrong to manually define all the tables and join conditions that are already available in the Model definitions.
Now I collect the values myself in an extra loop at the end after the query.
I think I just learn something from you anyway you can select values from joined tables, so maybe you don’t need loop? But I many times also did some extra work in PHP and quit thinking about super SQL queries if there is not many data.