We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Here's a real simple setup of two nested MIGXdb.
    I use this on a CMP, not as a TV on a resource.
    Everything works fine and as expected, but each time I create a new "lbChild", an error gets logged:
    (ERROR @ /assets/components/migx/connector.php) No foreign key definition for parentClass: lbParent using relation alias: Resource

    Schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <model package="lb_test" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    	<object class="lbParent" table="lb_parent" extends="xPDOSimpleObject" >
    		<field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
    		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
    			<column key="id" collation="A" null="false" />
    		</index>
    	</object>
    	<object class="lbChild" table="lb_child" extends="xPDOSimpleObject" >
    		<field key="parent" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
    		<field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
    		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
    			<column key="id" collation="A" null="false" />
    		</index>
    		<aggregate alias="Parent" class="lbParent" local="parent" foreign="id" cardinality="one" owner="foreign" />
    	</object>
    </model>

    Config "lb_parent":
    {"formtabs":[{"MIGX_id":1,"caption":"","print_before_tabs":"0","fields":[{"MIGX_id":1,"field":"title","caption":"Title","description":"","description_is_code":"0","inputTV":"","inputTVtype":"","configs":"","sourceFrom":"config","sources":"[]","inputOptionValues":"","default":""},{"MIGX_id":2,"field":"null","caption":"Children","description":"","description_is_code":"0","inputTV":"","inputTVtype":"migxdb","configs":"lb_children","sourceFrom":"config","sources":"[]","inputOptionValues":"","default":""}]}],"contextmenus":"update","actionbuttons":"addItem","columnbuttons":"","filters":"[]","extended":{"migx_add":"","formcaption":"","update_win_title":"","win_id":"lb_parent","maxRecords":"","multiple_formtabs":"","extrahandlers":"","packageName":"lb_test","classname":"lbParent","task":"","getlistsort":"","getlistsortdir":"","use_custom_prefix":"0","prefix":"","grid":"","gridload_mode":1,"check_resid":"0","check_resid_TV":"","join_alias":"","getlistwhere":"","joins":"","cmpmaincaption":"","cmptabcaption":"","cmptabdescription":"","cmptabcontroller":""},"columns":[{"MIGX_id":2,"header":"Id","dataIndex":"id","width":"","sortable":"false","show_in_grid":1,"renderer":"","clickaction":"","selectorconfig":"","renderoptions":"[]"},{"MIGX_id":1,"header":"Title","dataIndex":"title","width":"","sortable":"false","show_in_grid":1,"renderer":"","clickaction":"","selectorconfig":"","renderoptions":"[]"}]}

    Config "lb_children":
    {"formtabs":[{"MIGX_id":1,"caption":"","print_before_tabs":"0","fields":[{"MIGX_id":1,"field":"title","caption":"Title","description":"","description_is_code":"0","inputTV":"","inputTVtype":"","configs":"","sourceFrom":"config","sources":"[]","inputOptionValues":"","default":""}]}],"contextmenus":"update","actionbuttons":"addItem","columnbuttons":"","filters":"[]","extended":{"migx_add":"","formcaption":"","update_win_title":"","win_id":"lb_children","maxRecords":"","multiple_formtabs":"","extrahandlers":"","packageName":"lb_test","classname":"lbChild","task":"","getlistsort":"","getlistsortdir":"","use_custom_prefix":"0","prefix":"","grid":"","gridload_mode":2,"check_resid":1,"check_resid_TV":"","join_alias":"Parent","getlistwhere":"","joins":"","cmpmaincaption":"","cmptabcaption":"","cmptabdescription":"","cmptabcontroller":""},"columns":[{"MIGX_id":2,"header":"Id","dataIndex":"id","width":"","sortable":"false","show_in_grid":1,"renderer":"","clickaction":"","selectorconfig":"","renderoptions":"[]"},{"MIGX_id":1,"header":"Title","dataIndex":"title","width":"","sortable":"false","show_in_grid":1,"renderer":"","clickaction":"","selectorconfig":"","renderoptions":"[]"}]}

    "Parameter" for CMP:
    &configs=lb_parent

    MODX 2.2.7
    migx 2.4.3

    This question has been answered by labr1005. See the first response.

    [ed. note: labr1005 last edited this post 10 years, 11 months ago.]
    • The problem grows:

      If I create a relation to a resource for "lbParent" the error isn't logged, but an empty "lbParent" is saved to the database when creating a new "lbChild".

      Schema:
      <?xml version="1.0" encoding="UTF-8"?>
      <model package="lb_test" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
          <object class="lbParent" table="lb_parent" extends="xPDOSimpleObject" >
      		<field key="resource_id" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
              <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                  <column key="id" collation="A" null="false" />
              </index>
      		<aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" />
          </object>
          <object class="lbChild" table="lb_child" extends="xPDOSimpleObject" >
              <field key="parent" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
              <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
              <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                  <column key="id" collation="A" null="false" />
              </index>
              <aggregate alias="Parent" class="lbParent" local="parent" foreign="id" cardinality="one" owner="foreign" />
          </object>
      </model>
      • discuss.answer
          • 40762
          • 54 Posts
          Hey,

          I managed to make use of join in migxdb and I managed to make it work by reverse engineering it and getting the prefix of my element which was Joined_. I would like to change this if it is possible.

            Marc-Andre Audet
            • 4172
            • 5,888 Posts
            which prefix would you like to have, what is your current schema, what is your scenario/exported config?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!