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

    Im reading http://modxcms.com/about/blog/shaun-mccormick/storefinder.html
    right now.

    <field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
    <field key="address" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
    <field key="city" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
    [...]

    I wonder how to set up ENUM field.

    Another question is:
    Im writing application on MODx ’platform’. It’s just for particular situation. I don’t think I will be publishing it to MODx community or sth. Should I bother about what’s written in cited document: "Using Custom Database Tables in 3rd Party Component". Will it help me going this way.

    --
    Regards
    MM
      • 10487 MODX Staff
      • 1,535 Posts
      Garry Nutting Reply #2, 17 years ago
      Enums are specified in the schema in this format:
      <field key="address_type" dbtype="enum" precision="'BILLING','SHIPPING'" phptype="string" null="false" default="BILLING" />

      Also, I would stick with following the docs; even if you are creating a 3PC for your own use then they will still provide advice on best practice on how to make maintenance and upgrading in the future a lot easier.
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 17838
        • 82 Posts
        Great Thanks!

        And what about dbtype ’text’? Can I omit ’precision’ attribute?

        --
        Regards
        MM
          • 28215
          • 4,149 Posts
          splittingred Reply #4, 17 years ago
          Quote from: maciej.m at Sep 30, 2009, 12:45 PM

          And what about dbtype ’text’? Can I omit ’precision’ attribute?

          Yes. In fact, you have to.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 17838
            • 82 Posts
            And what about php-doc-package and php-doc-subpackage?

            If I omit those custom attributes shall I also cut following lines from build.schema.php?
            $generator->classTemplate= <<<EOD
            >?php
            /**
             * [+phpdoc-package+]
             */
            class [+class+] extends [+extends+] {
                function [+class+](& \$xpdo) {
                    \$this->__construct(\$xpdo);
                }
                function __construct(& \$xpdo) {
                    parent :: __construct(\$xpdo);
                }
            }
            ?>
            EOD;
            $generator->platformTemplate= <<<EOD
            <?php
            /**
             * [+phpdoc-package+]
             */
            require_once (strtr(realpath(dirname(dirname(__FILE__))), '\\\\', '/') . '/[+class-lowercase+].class.php');
            class [+class+]_[+platform+] extends [+class+] {
                function [+class+]_[+platform+](& \$xpdo) {
                    \$this->__construct(\$xpdo);
                }
                function __construct(& \$xpdo) {
                    parent :: __construct(\$xpdo);
                }
            }
            ?>
            EOD;
            $generator->mapHeader= <<<EOD
            <?php
            /**
             * [+phpdoc-package+]
             */
            EOD;


            BTW: Is there a mistake?
            $manager= $modx-<getManager();



            --
            Regards
            MM
              • 28215
              • 4,149 Posts
              splittingred Reply #6, 17 years ago
              Quote from: maciej.m at Sep 30, 2009, 03:05 PM

              And what about php-doc-package and php-doc-subpackage?

              If I omit those custom attributes shall I also cut following lines from build.schema.php?
              You can definitely do that; those are there mainly for phpDocumentor functionality.


              BTW: Is there a mistake?
              $manager= $modx-<getManager();

              Yep. Should be $modx->getManager();
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 17838
                • 82 Posts
                I got following errors:
                [2009-09-30 23:13:06] (ERROR @ /home/refleksolog/ftp/modx/core/xpdo/om/xpdogenerator.class.php : 450)
                
                PHP warning: mkdir() [function.mkdir]: No such file or directory
                [2009-09-30 23:13:06] (ERROR @ /home/refleksolog/ftp/modx/core/xpdo/om/xpdogenerator.class.php : 456)
                
                PHP warning: mkdir() [function.mkdir]: No such file or directory
                [2009-09-30 23:13:06] (ERROR @ /core/components/klimatyzacja/trunk/_build/build.schema.php)
                
                Could not open or create dir: /home/refleksolog/ftp/modx/core/components/klimatyzacja/trunk/core/components/klimatyzacja/model/klimatyzacja/
                [2009-09-30 23:13:06] (ERROR @ /core/components/klimatyzacja/trunk/_build/build.schema.php)
                
                Could not open or create dir: /home/refleksolog/ftp/modx/core/components/klimatyzacja/trunk/core/components/klimatyzacja/model/klimatyzacja/
                [2009-09-30 23:13:06] (ERROR @ /home/refleksolog/ftp/modx/core/xpdo/om/xpdogenerator.class.php : 536)
                
                PHP warning: mkdir() [function.mkdir]: No such file or directory
                [2009-09-30 23:13:06] (ERROR @ /home/refleksolog/ftp/modx/core/xpdo/om/xpdogenerator.class.php : 540)
                
                PHP warning: mkdir() [function.mkdir]: No such file or directory
                [2009-09-30 23:13:06] (ERROR @ /core/components/klimatyzacja/trunk/_build/build.schema.php)
                
                Could not open or create dir: /home/refleksolog/ftp/modx/core/components/klimatyzacja/trunk/core/components/klimatyzacja/model/klimatyzacja/mysql
                Execution time: 0.0815 s
                [2009-09-30 23:13:06] (WARN @ /home/refleksolog/ftp/modx/core/xpdo/om/xpdoobject.class.php : 932)
                
                PHP notice: A non well formed numeric value encountered


                Is it about permissions?
                  • 28215
                  • 4,149 Posts
                  splittingred Reply #8, 17 years ago
                  Hard to say without seeing your schema build script. Looks more like a path issue to me.
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 17838
                    • 82 Posts
                    Here’s build.schema.php
                    <?php
                    /**
                     * Build Schema script
                     *
                     * @package klimatyzacja
                     * @subpackage build
                     */
                    $mtime = microtime();
                    $mtime = explode(" ", $mtime);
                    $mtime = $mtime[1] + $mtime[0];
                    $tstart = $mtime;
                    set_time_limit(0);
                    
                    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(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
                    
                    $root = dirname(dirname(__FILE__)).'/';
                    $sources = array(
                        'root' => $root,
                        'core' => $root.'core/components/klimatyzacja/',
                        'model' => $root.'core/components/klimatyzacja/model/',
                        'assets' => $root.'assets/components/klimatyzacja/',
                        'schema' => $root.'_build/schema/',
                    );
                    
                    $manager= $modx->getManager();
                    $generator= $manager->getGenerator();
                    
                    $generator->parseSchema($sources['schema'].'klimatyzacja.mysql.schema.xml', $sources['model']);
                    
                    $mtime= microtime();
                    $mtime= explode(" ", $mtime);
                    $mtime= $mtime[1] + $mtime[0];
                    $tend= $mtime;
                    $totalTime= ($tend - $tstart);
                    $totalTime= sprintf("%2.4f s", $totalTime);
                    
                    echo "\nExecution time: {$totalTime}\n";
                    
                    exit ();
                    
                    ?>

                      • 17838
                      • 82 Posts
                      $sources = array(
                          'root' => $root,
                          'core' => $root.'core/components/klimatyzacja/',
                          'model' => $root.'core/components/klimatyzacja/model/',
                          'assets' => $root.'assets/components/klimatyzacja/',
                          'schema' => $root.'_build/schema/',
                      );


                      Should I create those folders by myself or script should do that?
                      Anyways I did that. Now i get:
                      [b][2009-10-01 19:54:59] (WARN @ /home/refleksolog/ftp/modx/core/xpdo/om/xpdoobject.class.php : 932)[/b]
                      
                      PHP notice: A non well formed numeric value encountered


                      And here’s my xml file:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <model package="klimatyzacja" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
                      <object class="klimaFirmy" table="klima_stores" extends="xPDOSimpleObject">
                      <field key="nazwa" dbtype="varchar" precision="250" phptype="string" null="false" default="" index="index" />
                      <field key="dzialalnosc" dbtype="text" phptype="string" null="false" default="" />
                      <field key="dzialalnosc_en" dbtype="text" phptype="string" null="false" default="" />
                      <field key="www" dbtype="varchar" precision="250" phptype="string" null="false" default="" />
                      <field key="email" dbtype="varchar" precision="250" phptype="string" null="false" default="" />
                      <field key="tel" dbtype="varchar" precision="30" phptype="string" null="false" default="" />
                      <field key="fax" dbtype="varchar" precision="30" phptype="string" null="false" default="" />
                      <field key="adres" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
                      <field key="miasto" dbtype="varchar" precision="30" phptype="string" null="false" default="" />
                      <field key="kod" dbtype="varchar" precision="10" phptype="string" null="false" default="" />
                      <field key="wpis" dbtype="enum" precision="'2','1','0'" phptype="string" null="false" default="0" />
                      <field key="logo" dbtype="varchar" precision="250" phptype="string" null="false" default="" />
                      <field key="logo_a" dbtype="enum" precision="'0','1'" phptype="string" null="false" default="0" />
                      <field key="rozsz" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
                      <field key="o_kont" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
                      <field key="o_kont" dbtype="varchar" precision="50" phptype="string" null="false" default="" />
                      <field key="em_kont" dbtype="varchar" precision="50" phptype="string" null="false" default="" />
                      <field key="o_kont" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
                      <field key="nazwa2" dbtype="varchar" precision="250" phptype="string" null="false" default="" index="index" />
                      <field key="adres2" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
                      <field key="kod2" dbtype="varchar" precision="10" phptype="string" null="false" default="" />
                      <field key="miasto2" dbtype="varchar" precision="30" phptype="string" null="false" default="" />
                      <field key="nip" dbtype="varchar" precision="30" phptype="string" null="false" default="" />
                      <field key="miasto" dbtype="int" precision="11" phptype="string" null="false" default="0" />
                      <field key="aktywacja" dbtype="enum" precision="'0','1'" phptype="string" null="false" default="0" />
                      <field key="data" dbtype="date" precision="11" phptype="string" null="false" default="" />
                      <field key="koniec" dbtype="date" precision="11" phptype="string" null="false" default="" />
                      <field key="polecamy" dbtype="enum" precision="'0','1'" phptype="string" null="false" default="0"/>
                      </object>
                      </model>