I want two to join two tables via getCollectionGraph()
.
Trailers
id | title |
---|---|
1 | My Trailer Name 1 |
2 | My Trailer Name 2 |
Dates
id | title | trailer_ids |
---|---|---|
3 | My Date Name 3 | 1,2 |
The result should be the following for a JSON API:
[
{
id: 1,
title: "My Trailer Name 1",
dates: [
{
id: 3,
title: "My Date Name 3"
}
…
]
}
…
]
A SQL join could be this:
FIND_IN_SET(Trailers.id, Dates.trailer_ids) > 0
Is there a way to add this criteria to getCollectionGraph()
in the Function or Schema?
$modx->getCollectionGraph('Trailers', '{ "Dates":{} }', $q);
Maybe I am thinking in the wrong direction and having a separate table for trailer_ids
is a better choice to set a classic relation. But im open for help and comments to get the right direction.