We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42841
    • 24 Posts
    Hi everyone,

    I'm following the Doodles example everyone else has been. I've created a schema, got the tables created, got the CMP in place - I just can't add any items. Basically, i'm showing a successful request to connector.php (status: 200), but the response is empty.

    The data I'm sending is:

    action:mgr/migxdb/update
    data:{"undefined":"","name":"All","sort":"sort-all"}
    configs:categories
    resource_id:
    co_id:
    object_id:new
    tv_id:2
    wctx:mgr
    HTTP_MODAUTH: {secret} 


    The MODx error log is showing:

    [2013-08-09 07:38:45] (ERROR @ /recipe-app/assets/components/migx/connector.php) Could not load class: Categories from mysql.categories.
    


    I've noticed the classes are empty also.

    <?php
    class Categories extends xPDOSimpleObject {}


    I'm attempting to use MIGX 2.5.6 with Revo 2.2.8 on a PHP5 server.

    My Schema is:

    <?xml version="1.0" encoding="UTF-8"?>
    <model package="recipes" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
        <object class="Recipe" table="recipes" extends="xPDOSimpleObject">
            <field key="resource_id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" generated="native"/>
            <field key="fbid" dbtype="varchar" precision="64" phptype="string" null="false" default=""/>
            <field key="first_name" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
            <field key="last_name" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
            <field key="email" dbtype="varchar" precision="128" phptype="string" null="false" default=""/>
            <field key="opt_in" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
    
            <field key="title" dbtype="varchar" precision="70" phptype="string" null="false" default=""/>
            <field key="serves" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
            <field key="origin" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
            <field key="ingredients" dbtype="mediumblob" phptype="string" null="false" default=""/>
            <field key="method" dbtype="mediumblob" phptype="string" null="false" default=""/>
            <field key="image" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    
            <field key="loves" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0"/>
            <field key="views" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0"/>
            <field key="category" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0"/>
            <field key="block" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0"/>
    
            <field key="status" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
            <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
            <field key="lastedit" dbtype="datetime" phptype="datetime" null="true"/>
    
            <aggregate alias="" class="Categories" local="category" foreign="id" cardinality="one" owner="foreign"/>
            <aggregate alias="" class="Blocks" local="block" foreign="id" cardinality="one" owner="foreign"/>
        </object>
        <object class="Categories" table="categories" extends="xPDOSimpleObject">
            <field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" generated="native"/>
            <field key="name" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
            <field key="sort" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
        </object>
        <object class="Blocks" table="categories" extends="xPDOSimpleObject">
            <field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk" generated="native"/>
            <field key="image" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
            <field key="sort" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
        </object>
    </model>


    With the only error message as above, and a successful/errorless request to connector.php I'm lost as to what to try next.

    Any ideas? [ed. note: ahrenks last edited this post 13 years, 2 months ago.]
      • 4172
      • 5,888 Posts
      you shouldn't have a id - field in your schema, when extending xPDOSimpleObject

      remove the id - fields from schema and run 'parse schema' again, then try it again.

      Make sure, you have the check Resource - setting to 'no'
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42841
        • 24 Posts
        Hi Bruno, thanks for the hint!

        How will this work with the aggregate relationship? What would the foreign key be?
          • 4172
          • 5,888 Posts
          xPDOSimpleObject does use the id-field of your table automatically, you don't need to have it in your schema.
          your aggregates do look ok as they are.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 42841
            • 24 Posts
            Cool.

            Okay, all the tables are created again - but the classes are still empty. Nothing in the error log.

            When I try and add a category, I get the following in the error log:

            [2013-08-09 19:31:52] (ERROR @ /recipe-app/assets/components/migx/connector.php) Could not load class: Categories from mysql.categories.
            [2013-08-09 19:31:59] (ERROR @ /recipe-app/assets/components/migx/connector.php) Could not load class: Categories from mysql.categories.
              • 4172
              • 5,888 Posts
              Can you do an export (right-click in the MIGX-config-grid->import/export) of your categories-config and post it here?

              [edit]
              emtpy classes are normal. They do not have any functions by default.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 42841
                • 24 Posts
                Found the problem! Now I can save Categories and Blocks, thank you!

                I had two problems, one I didn't set the custom prefix in those configs, and two I had Recipes as the package name instead of recipes.

                One last question if I may... I have two listboxes in my Recipe. One for the Category and one for the Block. How do I wire these up? (they're currently just showing empty list boxes - even though I've got one category and one block now)

                Thanks for your help so far

                [edit]
                Also, do you have a donation method? I like MIGX a lot!

                [edit2]
                I notice the recipes save properly now, but don't show in the grid.
                I get this in the error log:

                 [2013-08-09 20:12:04] (ERROR @ /whittakers-recipe/assets/components/migx/connector.php) Error 42S22 executing statement: 
                Array
                (
                    [0] => 42S22
                    [1] => 1054
                    [2] => Unknown column 'Recipe.deleted' in 'where clause'
                )
                [ed. note: ahrenks last edited this post 13 years, 2 months ago.]
                  • 4172
                  • 5,888 Posts
                  If possible, change your tables and schema for not needing a custom-prefix.
                  Custom-prefixes can lead to confusions and different issues.

                  Then you can use migxLoopCollection to build the input-options for your listboxes.

                  @EVAL return 'select one==||' . $modx->runSnippet('migxLoopCollection',array('packageName'=>'recipes','classname'=>'Categories','tpl'=>'@CODE:[[+name]]==[[+id]]','outputSeparator'=>'||'));


                  or

                  @CHUNK getCategoriesOptions


                  chunk getCategoriesOptions:

                  [[migxLoopCollection?
                  &packageName=`recipes`
                  &classname=`Categories`
                  &tpl=`@CODE:[[+name]]==[[+id]]`
                  &outputSeparator=`||`
                  ]]


                  If you still have a custom-prefix don't forget it to the snippet-call:

                  &prefix=`yourCustomPrefix`
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 42841
                    • 24 Posts
                    Yeah cool, that's worked perfectly!

                    The only problem now is my [edit2] above.

                    (Recipes save in the database, but don't show on the grid).
                    Error log:

                    [2013-08-09 20:12:04] (ERROR @ /whittakers-recipe/assets/components/migx/connector.php) Error 42S22 executing statement: 
                    Array
                    (
                        [0] => 42S22
                        [1] => 1054
                        [2] => Unknown column 'Recipe.deleted' in 'where clause'
                    )
                      • 4172
                      • 5,888 Posts
                      you don't have a 'deleted' - field in your table, so you need to remove the 'toggletrash' - Actionbutton
                      otherwise the getlist-processor is trying to filter by deleted/not deleted
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!