We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19534
    • 183 Posts
    yes, that’s right. But as you wrote you’ll lose all the nice xPDO features...
      Add-On to easily manage your multilingual sites: Babel
      • 6228
      • 249 Posts
      Assuming it’s an xPDO bug, for now I’ve just split my call into two distinct queries - one to fetch a set of division IDs that match my select criteria, and then a second query that fetches a collection graph of division-related objects. I set each query to cache so the performance impact is minimal.
        lo9on.com

        MODx Evolution/Revolution | Remote Desktop Training | Development
        • 33968
        • 863 Posts
        I’ve come across this exact same issue in Revo 2.1.1-pl.

        Top level I get all rows.
        - First nested level I get all rows.
        -- Second nested level I get only one - the LAST row.

        Did anyone ever find a solution or can we all agree it is a bug?
        Let me know as I’m about to file this on the bug list (if it’s not there already)...
          • 16348
          • 64 Posts
          I have encountered the same problem but my problem is when I’m trying to use a call with four levels.

          I have a model with a relationship between my classes Categories and Results. Results also has a relationship to the moduser class. Here is the relevant parts of the schema file:
          <object class="Categories" table="entry_categories" extends="xPDOSimpleObject">
            <field key="categoryid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="index" />
            ...	
            <composite alias="Entries" class="Results" local="categoryid" foreign="categoryid" cardinality="many" owner="local" />
          </object>
          
          <object class="Results" table="entry_results" extends="xPDOSimpleObject">
            <field key="competitorid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" index="index" />
            <field key="categoryid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="index" />
            ...		
            <aggregate alias="Category" class="Categories" local="categoryid" foreign="categoryid" cardinality="one" owner="foreign" />
            <aggregate alias="User" class="modUser" local="competitorid" foreign="id" cardinality="one" owner="foreign" />
          </object>
          


          This code doesn’t work (the same results as the earlier posts):
          $entrants = $modx->getCollectionGraph('Categories', '{"Entries": {"User":{"Profile":{}}}}');
          


          For now, I’m using this solution instead:
          $categories = $modx->getIterator('Categories');
            foreach ($categories as $category) {
              $entrants = $modx->getCollectionGraph('Results', '{"User":{"Profile":{}}}');
              ...
            }
          
            • 38176
            • 2 Posts
            same problem here with modx-2.2.0-dev-123111
            diffrent results with changing graph order
            $uds = $modx->getCollectionGraph('bccUserDay','{"bccDays":{"bccSchedule":{"bccAct":{}}},"bccUser":{"PrimaryGroup":{},"Profile":{},"bccUserSchedule":{}}}',array('bccUserDay.uid'=>$userid,'bccDays.date'=>$date));

            and
            $uss = $modx->getCollectionGraph('bccUserSchedule','{"bccUser":{"PrimaryGroup":{},"Profile":{}},"bccSchedule":{"bccAct":{},"bccDays":{"bccUserDay":{}}}}',array('bccUserSchedule.uid'=>$userid,'bccDays.date'=>$date));

            are diffrent in modx
            but same result in phpmyadmin with executing query

            this is my schema file:
            <?xml version="1.0" encoding="UTF-8"?>
            <model package="bugcc" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="bugcc_" version="1.1">
            	<object class="bccUser" table="users" extends="modUser">
            		<composite alias="bccUserDay" class="UserbccDay" local="id" foreign="uid" cardinality="many" owner="local" />
            		<composite alias="bccUserSchedule" class="bccUserSchedule" local="id" foreign="uid" cardinality="many" owner="local" />
            	</object>
            	<object class="bccGroup" table="membergroup_names" extends="modUserGroup">
            		<composite alias="Schedule" class="bccSchedule" local="id" foreign="cid" cardinality="many" owner="local" />
            	</object>
            	<object class="bccAct" table="bugcc_act" extends="xPDOSimpleObject">
            		<field key="name" dbtype="varchar" precision="256" phptype="string" null="false" />
            		<field key="desc" dbtype="text" phptype="string" null="true" />
            		<field key="del" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
            		
            		<composite alias="bccSchedule" class="bccSchedule" local="id" foreign="aid" cardinality="many" owner="local" />
            	</object>
            	<object class="bccDays" table="bugcc_days" extends="xPDOSimpleObject">
            		<field key="date" dbtype="date" phptype="date" null="false" index="unique" />
            		<field key="desc" dbtype="text" phptype="string" null="true" />
            
            		<index alias="date" name="date" primary="false" unique="true" type="BTREE" >
            			<column key="date" length="" collation="A" null="false" />
            		</index>
            		
            		<composite alias="bccSchedule" class="bccSchedule" local="id" foreign="did" cardinality="many" owner="local" />
            		<composite alias="bccUserDay" class="bccUserDay" local="id" foreign="did" cardinality="many" owner="local" />
            	</object>
            	<object class="bccSchedule" table="bugcc_schedule" extends="xPDOSimpleObject">
            		<field key="cid" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" index="index" />
            		<field key="aid" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" />
            		<field key="did" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" />
            
            		<index alias="cid" name="cid" primary="false" unique="true" type="BTREE" >
            			<column key="cid" length="" collation="A" null="false" />
            			<column key="aid" length="" collation="A" null="false" />
            			<column key="did" length="" collation="A" null="false" />
            		</index>
            		
            		<aggregate alias="bccGroup" class="bccGroup" local="cid" foreign="id" cardinality="one" owner="foreign"/>
            		<aggregate alias="bccAct" class="bccAct" local="aid" foreign="id" cardinality="one" owner="foreign"/>
            		<aggregate alias="bccDays" class="bccDays" local="did" foreign="id" cardinality="one" owner="foreign"/>
            		<composite alias="bccUserSchedule" class="bccUserSchedule" local="id" foreign="sid" cardinality="many" owner="local" />
            	</object>
            	<object class="bccUserDay" table="bugcc_userday" extends="xPDOObject">
            		<field key="did" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" index="pk" />
            		<field key="uid" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" index="pk" />
            		<field key="desc" dbtype="text" phptype="string" null="false" />
            
            		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
            			<column key="did" length="" collation="A" null="false" />
            			<column key="uid" length="" collation="A" null="false" />
            		</index>
            		
            		<aggregate alias="bccDays" class="bccDays" local="did" foreign="id" cardinality="one" owner="foreign"/>
            		<aggregate alias="bccUser" class="bccUser" local="uid" foreign="id" cardinality="one" owner="foreign"/>
            	</object>
            	<object class="bccUserSchedule" table="bugcc_userschedule" extends="xPDOObject">
            		<field key="sid" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" index="pk" />
            		<field key="uid" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" index="pk" />
            		<field key="desc" dbtype="text" phptype="string" null="true" />
            
            		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
            			<column key="sid" length="" collation="A" null="false" />
            			<column key="uid" length="" collation="A" null="false" />
            		</index>
            		
            		<aggregate alias="bccSchedule" class="bccSchedule" local="sid" foreign="id" cardinality="one" owner="foreign"/>
            		<aggregate alias="bccUser" class="bccUser" local="uid" foreign="id" cardinality="one" owner="foreign"/>
            	</object>
            </model>

              • 22303 MODX Staff
              • 10,725 Posts
              The current algorithm for loading the related graph objects gets confused if you try to load more than one relationship that is of cardinality equal many. See bug #5159 and feature request #5535 for reference.