Create dynamic resources from migxdb

Works great, thank you!


Actually I don’t even have to run it again, as the page gets the category fields already through the initiating snippet from above. So all I had to do was the following but I needed your calrification to get that:

&where=`{"`ReferenzKategorien`.`kategorie_id`": [[+id]]}`

As I’m still trying to understand the whole joining of tables and query part better, can you tell me if the alias in the &join parameter is like a fixed value or what does it mean exactly? If there’s any resources I can learn from in more detail, please let me know.


Well, I tried it again with double slashes and it indeed worked, too. I assume, I made some other mistake before as I’m pretty sure I only got a blank page, which changed after I changed this. But maybe also a caching issue, or something.


Anyway, I think I got most of this working now. I’ll let this thread open for a bit, in case something else pops. Thank you @bruno17 and especially @halftrainedharry for the great help. I really appreciate it!

[[migxLoopCollection?
  &classname=`Client\Model\clientReferenz`
  &joins=`[{"alias": "ReferenzKategorien"}]`

In this case it means, that we want to query the table client_referenzen (class Client\Model\clientReferenz) and combine it with the table client_referenzkategorie as defined in the schema by the relationship with the alias = “ReferenzKategorien”:

<composite alias="ReferenzKategorien" class="Client\Model\clientReferenzKategorie" local="id" foreign="referenz_id" cardinality="many" owner="local" />

The code knows from the <composite> tag which columns to use for the join (local="id" foreign="referenz_id"). It’s just simpler to use the “alias” than defining the relationship by hand in &joins (which you can do as well → {"alias":"...","classname":"...","on":"... = ..."}).

1 Like