We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18373 ☆ A M B ☆
    • 3,141 Posts
    That’s creating the database tables.


    How do you parse the schema you created to create the model (classes)? Or are you reverse engineering it from a database table?
      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
      • 34084 ☆ A M B ☆
      • 756 Posts
      duh, sorry been a long morning.

      <?php
      require_once dirname(__FILE__).'/build.config.php';
      include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
      $modx= new modX();
      $modx->initialize('mgr');
      $modx->loadClass('transport.modPackageBuilder','',false, true);
      $modx->setLogLevel(modX::LOG_LEVEL_INFO);
      $modx->setLogTarget('ECHO');
       
      $root = dirname(dirname(__FILE__)).'/';
      $sources = array(
          'model' => $root.'core/components/awdbios/model/',
          'schema_file' => $root.'core/components/awdbios/model/schema/awdbios.mysql.schema.xml',
      );
      $manager= $modx->getManager();
      $generator= $manager->getGenerator();
       
      if (!is_dir($sources['model'])) { $modx->log(modX::LOG_LEVEL_ERROR,'Model directory not found!'); die(); }
      if (!file_exists($sources['schema_file'])) { $modx->log(modX::LOG_LEVEL_ERROR,'Schema file not found!'); die(); }
      $generator->parseSchema($sources['schema_file'],$sources['model']);
       
      echo 'Done.';
      exit();
        Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
        Visit CharlesMx.com for latest news and status updates.
        • 40804
        • 7 Posts
        Did you manage to get a solution for this? I am having the same issue... really frustrating as I am not sure what I have done wrong.
          • 38713
          • 91 Posts
          alexmercenary Reply #24, 14 years ago
          I can't get this working either. Get to the point of running the snippet from a resource and nothing is output and no table is being created. That's pretty much where i'm at and have been for ages... Can't figure it out... I'm certain case sensitivity is spot on for the names and classes.

          Basically someone please save me.
            Twitter @alexmercenary
            • 38713
            • 91 Posts
            alexmercenary Reply #25, 14 years ago
            Still absolutely baffled by all this. I've got it all set up identically to the tut that shaun did and i've tried using the bits off github.

            Just getting this, like charless:

            [2012-09-21 14:25:26] (ERROR @ /siteroot/index.php) Could not load class: Doodles from doodles.
            [2012-09-21 14:25:26] (ERROR @ /siteroot/index.php) Problem getting service doodles, instance of class Doodles, from path /Path/To/doodles/core/model/doodles/
            [2012-09-21 14:25:26] (ERROR @ /siteroot/index.php) Could not load class: Doodle from mysql.doodle.
              Twitter @alexmercenary
              • 4172
              • 5,888 Posts
              you can try to create your package/classes/tables with help of MIGXdb:

              http://rtfm.modx.com/display/ADDON/MIGXdb.Create+doodles+manager+with+help+of+MIGXdb

              as soon, as you have your schema ready this takes typically less than 5 minutes. (to create the package,classes,map-files and tables)
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 38713
                • 91 Posts
                alexmercenary Reply #27, 14 years ago
                Sorry for the late reply! Thanks Bruno i will use MIGXdb then and see how i get on!
                  Twitter @alexmercenary
                  • 38713
                  • 91 Posts
                  alexmercenary Reply #28, 14 years ago
                  Thanks Bruno that's pretty damn cool. Nice and easy.
                    Twitter @alexmercenary
                    • 17403 ☆ A M B ☆
                    • 183 Posts
                    Following Doddle tutorial part "Building the Query"(http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution), generate persistent error on Revo 2.2.5 and above: Class "MyAddon_mysql" not found.

                    That's weird because in MODX version 2.1 and below, I successfully create a table using same method (http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution+-+MODX+2.1+and+Earlier).



                    [ed. note: lokamaya last edited this post 13 years, 9 months ago.]
                      zaenal.lokamaya
                      • 17403 ☆ A M B ☆
                      • 183 Posts
                      Oh, my fault. I have a complex schema in my package "catalogorder".

                      //ERROR
                      //provide packageName "catalogorder" return ERROR: Class "catalogorder_mysql" not found.
                      $modx->getManager()->createObjectContainer('catalogorder');
                      
                      //SUCCESS
                      //provide objectClass "Order", "OrderHistory", "OrderProduct"
                      $modx->getManager()->createObjectContainer('Order');
                      $modx->getManager()->createObjectContainer('OrderHistory');
                      $modx->getManager()->createObjectContainer('OrderProduct');



                      Here my schema
                      <?xml version="1.0" encoding="UTF-8"?>
                      <model package="catalogorder" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
                          <object class="Order" table="catalog_order" extends="xPDOObject">
                              <field key="id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="pk"  generated="native" />
                              <field key="order_key" dbtype="varchar" precision="64" phptype="string" null="false" index="unique" />
                              ....
                              <composite alias="dataProduct" class="OrderProduct" local="id" foreign="order_id" cardinality="many" owner="local" />
                              <composite alias="dataHistory" class="OrderHistory" local="id" foreign="order_id" cardinality="many" owner="local" />
                              <aggregate alias="customer" class="modUser" local="user_id" foreign="id" cardinality="one" owner="foreign"/>
                          </object>
                          
                          <object class="OrderHistory" table="catalog_order_history" extends="xPDOObject">
                              <field key="history_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="pk"  generated="native" />
                              <field key="order_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="index" />
                              ....
                              <aggregate alias="dataOrder" class="Order" local="order_id" foreign="id" cardinality="one" owner="foreign" />
                          </object>
                          
                          <object class="OrderProduct" table="catalog_order_product" extends="xPDOObject">
                              <field key="order_product_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="pk"  generated="native" />
                              <field key="order_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="index" />
                              ....
                              <aggregate alias="dataOrder" class="Order" local="order_id" foreign="id" cardinality="one" owner="foreign" />
                          </object>
                      </model>
                      [ed. note: lokamaya last edited this post 13 years, 9 months ago.]
                        zaenal.lokamaya