Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nesting MIGXdb problems #95

Closed
labr1005 opened this issue Jun 3, 2013 · 1 comment
Closed

Nesting MIGXdb problems #95

labr1005 opened this issue Jun 3, 2013 · 1 comment

Comments

@labr1005
Copy link

labr1005 commented Jun 3, 2013

I really tried to figure this out for myself, changed all the names to avoid conflicts, tried "Join Alias" and "Joins", … I'm really stuck and ask for your help.

I want to nest two MIGXdb. I can provide you with more informations like JSON-configs, etc. But I really think they are ok. So here are only the main points:

###

On a CMP

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="" /> <composite alias="Children" class="lbChild" local="id" foreign="parent" cardinality="many" owner="local" /> </object> <object class="lbChild" table="lb_child" extends="xPDOSimpleObject" > <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default="" /> <field key="parent" dbtype="int" precision="11" phptype="integer" null="false" default="0" /> <aggregate alias="Parent" class="lbParent" local="parent" foreign="id" cardinality="one" owner="foreign" /> </object> </model>

Config "lb_parent":

  • Check Resource "no"

Config "lb_children":

  • Check Resource "yes"
  • Join Alias "Parent"

Problem:
Every time a new "Child" is created, this error is logged:
(ERROR @ /assets/components/migx/connector.php) No foreign key definition for parentClass: lbParent using relation alias: Resource

Everything else seems to work fine.

###

On Resources as a TV

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="" /> <field key="resource_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" /> <aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" /> <composite alias="Children" class="lbChild" local="id" foreign="parent" cardinality="many" owner="local" /> </object> <object class="lbChild" table="lb_child" extends="xPDOSimpleObject" > <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default="" /> <field key="parent" dbtype="int" precision="11" phptype="integer" null="false" default="0" /> <aggregate alias="Parent" class="lbParent" local="parent" foreign="id" cardinality="one" owner="foreign" /> </object> </model>

Config "lb_parent":

  • Check Resource "yes"

Config "lb_children":

  • Check Resource "yes"
  • Join Alias "Parent"

Problem:
As soon as there is a second "Child" created, a new "Parent" is created in the database with a blank "title" and "resource_id" incrementing.

###

MODX 2.2.7
MIGX 2.4.3

@labr1005
Copy link
Author

Thanks Bruno for your help!

Anybody else: In both cases you need to create a new update-processor for your component.
Copy this file

/core/components/migx/processors/mgr/default/update.php

to

/core/components/your_component/processors/mgr/default/update.php

and comment out/delete the block "handle join-table" starting with

if (!empty($joinalias)) {

in MIGX 2.5.1 at around line 229.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant