This question has been answered by imjamespeter. See the first response.
$c = $modx->newQuery('modUser'); $c->sortby('fullname', 'ASC'); $c->where( array('Data.last_name' => 'Johnson'), ); $users = $modx->getCollectionGraph('modUser', '{"Profile":{},"Data":{}}', $c);
foreach ($users as $user) { $pFields = $user->Profile->toArray(); $dFields = $user->Data->toArray(); $ufields = $user->toArray(); $allFields = array_merge($pFields, $dFields, $uFields); $output .= $modx->getChunk('MyTpl', $allFields); }
<?xml version="1.0" encoding="UTF-8"?> <model package="Catalog" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="Data1" table="data1" extends="xPDOSimpleObject"> <field key="model_number" dbtype="varchar" precision="255" phptype="string" null="false" /> <field key="number_of_corners" dbtype="decimal" precision="3,1" phptype="float" null="false" /> <field key="depth_of_groove" dbtype="decimal" precision="4,2" phptype="float" null="false" /> </object> <object class="Data2" table="data2" extends="xPDOSimpleObject"> <field key="model_number" dbtype="varchar" precision="255" phptype="string" null="false" /> <field key="fabric" dbtype="decimal" precision="7,5" phptype="float" null="false" /> <field key="coating" dbtype="varchar" precision="255" phptype="string" null="true" /> </object> <object class="Data3" table="data3" extends="xPDOSimpleObject"> <field key="model_number" dbtype="varchar" precision="255" phptype="string" null="false" /> <field key="height" dbtype="decimal" precision="6,2" phptype="float" null="false" /> <field key="width" dbtype="decimal" precision="6,2" phptype="float" null="false" /> </object> </model>
[[migxLoopCollection? &classname=`modUser` &joins=`[{"alias":"Profile"}]` &tpl=`yourTplChunk` ]]
[[+Profile_street]]
[[migxLoopCollection? &packageName=`Catalog` &classname=`Data1` &joins=`[ {"alias":"Data2","classname":"Data2","on":"Data2.model_number=Data1.model_number"}, {"alias":"Data3","classname":"Data3","on":"Data3.model_number=Data1.model_number"} ]` &tpl=`yourTplChunk` &where=`{"Data1.model_number":"themodelnumber"}` ]]