# MIGX Joins Statements

**URL:** <https://community.modx.com/t/migx-joins-statements/7115>\
**Category:** Extras\
**Tags:** migx, migxdb, revo-3\
**Created:** [October 5, 2023, 7:54am UTC](https://community.modx.com/t/migx-joins-statements/7115 "2023-10-05T07:54:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![excavator](https://community.modx.com/user_avatar/community.modx.com/excavator/32/3349_2.png) [@excavator](https://community.modx.com/u/excavator)\
**Post date:** [October 5, 2023, 7:54am UTC](https://community.modx.com/t/migx-joins-statements/7115/1 "2023-10-05T07:54:28Z")

</div>

Using the following schema:

```xml
<object class="Drzave" table="history_drzave" extends="xPDO\Om\xPDOSimpleObject">
    <field key="naziv" dbtype="varchar" phptype="string" precision="100" null="false" default=""/>
    <field key="short" dbtype="varchar" phptype="string" precision="100" null="false" default=""/>
    <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />        
</object>

<object class="Tekmovalci" table="history_tekmovalci" extends="xPDO\Om\xPDOSimpleObject">
    <field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
    <field key="surname" dbtype="varchar" precision="255" phptype="string" null="false" default="" />

    <field key="drzava_id" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />
    <aggregate alias="Drzava" class="History\Model\Drzave" local="drzava_id" foreign="id" cardinality="one" owner="foreign" />

    <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />

    <index alias="drzava_id" name="drzava_id" primary="false" unique="false" type="BTREE" >
        <column key="drzava_id" length="" collation="A" null="false" />
    </index>

</object>

```

what is the correct way to construct a “join” clause for MIGX CMP? I’ve tried this and a bunch of other similar ones (without full class names … nothing worked). In the column, I am calling “drzava\_short” to try and get the data, since that worked on MODX 2 without issues.

```json
[{"alias":"drzava","classname":"History\Model\Drzave","on":"Tekmovalci.drzava_id = Drzava.id"}]

```

Using MODX 3.0.3, latest MIGX (3.0.2-beta1), PHP 8.1

Error log has:

```auto
No class specified for loadClass
No class specified for loadClass
::getSelectColumns() is not a valid static method.

```

so I believe it’s something I’m missing with my class definitions in the joins …

---

<div class="post-metadata">

**Author:** ![excavator](https://community.modx.com/user_avatar/community.modx.com/excavator/32/3349_2.png) [@excavator](https://community.modx.com/u/excavator)\
**Post date:** [October 5, 2023, 8:49am UTC](https://community.modx.com/t/migx-joins-statements/7115/2 "2023-10-05T08:49:12Z")

</div>

Just using `[{"alias":"Drzava"}]` worked. 🙂

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [October 5, 2023, 9:05am UTC](https://community.modx.com/t/migx-joins-statements/7115/3 "2023-10-05T09:05:30Z")

</div>

> [@excavator](#):
>
> `[{"alias":"drzava","classname":"History\Model\Drzave","on":"Tekmovalci.drzava_id = Drzava.id"}]`

The problem here are the backslashes (`\`) that have to be escaped (to make it valid JSON).

This string in the “Joins” field should work as well:

```json
[{"alias":"Drzava","classname":"History\\Model\\Drzave","on":"Tekmovalci.drzava_id = Drzava.id"}]

```

---

<div class="post-metadata">

**Author:** ![system](https://community.modx.com/user_avatar/community.modx.com/system/32/2_2.png) [@system](https://community.modx.com/u/system)\
**Post date:** [October 7, 2023, 9:06am UTC](https://community.modx.com/t/migx-joins-statements/7115/4 "2023-10-07T09:06:01Z")

</div>

Closed on October 7, 2023, 9:06am UTC

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.
