We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50441
    • 13 Posts
    Can anyone please point me in the right direction.

    I have used MigX to create a CMP page for single custom tables with some success.

    I now need to repeat the exercise with two related tables, one to many. The tables are fine - BUT I have not the slightest inkling how to start
    creating a CMP that will allow CRUD on 2 related tables. The only write-ups I can find are very old - pre-2.3 - or focus heavily on editing the JSON file.

    Any help on how to approach this would be most welcome.

    With thanks in advance ...

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

    [ed. note: nowhinjing1 last edited this post 7 years, 11 months ago.]
      • 4172
      • 5,888 Posts
      can you show your xpdo-schema with that tables?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 50441
        • 13 Posts
        with pleasure

        <?xml version="1.0" encoding="UTF-8"?>
        <model package="curconv" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.0">
            <object class="CCbase" table="ccbase" extends="xPDOSimpleObject">
                <field key="basecur" dbtype="varchar" precision="3" phptype="string" null="false" default=""/>
                <field key="updatedon" dbtype="datetime" phptype="datetime" null="false"/>
                <field key="description" dbtype="text" phptype="string" null="false" default=""/>
                <field key="symbol" dbtype="varchar" precision="3" phptype="string" null="false" default=""/>
                <field key="uprate" dbtype="decimal" precision="5,4" phptype="float" null="false" default="0"/>
                <field key="rnupdn" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
                <field key="rndlvl" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0" />
                <field key="appid" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
                <field key="upmins" dbtype="int" precision="4" attributes="unsigned" phptype="integer" null="false" default="0"/>
                
                <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> 
               
                <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                <field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
                <field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
                <field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
                
                <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                        <column key="basecur" collation="A" null="false" />
                </index>
                <composite alias="CCentry" class="CCentry" local="basecur" foreign="basecur" cardinality="many" owner="local" /> 
                <aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
                <aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
            </object>
        
            <object class="CCentry" table="ccentry" extends="xPDOSimpleObject">
                <field key="basecur" dbtype="varchar" precision="3" phptype="string" null="false" default=""/>
                <field key="entrycur" dbtype="varchar" precision="3" phptype="string" null="false" default=""/>
                <field key="description" dbtype="text" phptype="string" null="false" default=""/>
                <field key="exrate" dbtype="decimal" precision="10,4" phptype="float" null="false" default="0"/>
                
                <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> 
                
                <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                <field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
                <field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
                <field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
                
                <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                        <column key="entrycur" collation="A" null="false" />
                </index>
                <aggregate alias="CCbase" class="CCbase" local="basecur" foreign="basecur" cardinality="one" owner="foreign" /> 
                <aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
                <aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
            </object>
        </model>
        
          • 4172
          • 5,888 Posts
          question: why do you connect them by basecur and not by the id of the CCbase - record?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 50441
            • 13 Posts
            no particular reason - it just made it easier when I was testing the snippets ...
            • discuss.answer
              • 50441
              • 13 Posts
              OK got it now ...

              For other thickos like me the tip is to read up on nested MigX definitions - the top one for the main table and a subordinate definition for the linked table.

              Easy, really but I will produce a simple tutorial to help others as and when I find time.

              Just one thing I can't figure out - when you add an item in the linked table how can you pre-populate the link id to the base table ?

              There must be a way ....

              Bruno, help !
                • 50441
                • 13 Posts
                doh!

                try turning check resource id on .....

                then it works as it should.

                sorry to be such a dumb-ass !
                  • 26503
                  • 620 Posts
                  Quote from: nowhinjing1 at May 13, 2016, 03:14 AM
                  OK got it now ...

                  For other thickos like me the tip is to read up on nested MigX definitions - the top one for the main table and a subordinate definition for the linked table.

                  Easy, really but I will produce a simple tutorial to help others as and when I find time.

                  Just one thing I can't figure out - when you add an item in the linked table how can you pre-populate the link id to the base table ?

                  There must be a way ....

                  Bruno, help !

                  Where did you find this info on "nested MigX definitions" google is showing nothing -0- I've been struggling with this same problem for a whole WEEK now with no help, old docs and forum posts that end with "why not try something else" getting overly frustrated.
                    *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                    Sean Kimball CLP, CLS.
                    Technical Director / Sr. Developer | BigBlock Studios
                    ._______________________________________________.
                    Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                    27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                    phone/fax: 905-426-5525