We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7966
    • 90 Posts
    Using the MODx Revolution 2.0.4-pl2 on local server.

    I created the table with exact name "bobs_quotation", downloaded the CreateXpdoClasses, and added into a snippet (without any changes in code).

    I got the following message after running CreateXpdoClasses.

    [2010-10-24 22:34:42] (INFO @ /modxtest/index.php)
    
    Schema file written to C:\xampp\htdocs\modxtest/core/components/quotes/schema/quotes.mysql.schema.xml
    
    [2010-10-24 22:34:42] (INFO @ /modxtest/index.php)
    
    Schema file parsed -- Files written to C:\xampp\htdocs\modxtest/core/components/quotes/model/
    
    [2010-10-24 22:34:42] (INFO @ /modxtest/index.php)
    
    FINISHED


    Under "C:\xampp\htdocs\modxtest\core\components\quotes\schema" --> quotes.mysql.schema.xml file exists.

    "C:\xampp\htdocs\modxtest\core\components\quotes\model\quotes\mysql" directory is empty. Quotes directory is also empty.


    • Did you make the directory writeable? I had issues unless the directory was 777
        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
        AugmentBLU - MODX Partner

        BLUcart - MODX Revolution E-Commerce & Shopping Cart
        • 818
        • 23 Posts
        Quote from: BobRay at Oct 24, 2010, 04:44 AM

        Does the table you’re trying to process look normal in the DB (does it have fields and indexes and some content)?

        That works! Misspelled the table prefix..
        Thanks a lot for the help and the tutorial, saved me hours of headache!
          • 3749
          • 24,544 Posts
          Sorry, my fault, again. The code creates the directories, but doesn’t specify a permission for them. I’ve been meaning to change the code to make them 777. It should be OK now.

          I’m glad you got it working.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 4971
            • 964 Posts
            Bob, thanks for the excellent snippet and tutorial...

            does the following has to be run every single time? or just at the beginning...

            $path = MODX_CORE_PATH . 'components/reader/';
            $result = $modx->addPackage('reader',$path . 'model/','mxp_');
              Website: www.mercologia.com
              MODX Revo Tutorials:  www.modxperience.com

              MODX Professional Partner
              • 11155
              • 74 Posts
              I’m wondering too !?

              Also, as a non PHP expert, who also discovers xpdo now, what’s the easiest method to get the number of rows in my custom table ?
              I tried:
              $path = MODX_CORE_PATH . 'components/blabla/model/';
              $modx->addPackage('blabla', $path, 'bla_');
              
              $nbrows = count($modx->getCollection('Mytable'));
              


              Which kind of works except that it retrieves every row in the table if I understand, and as my table currently holds 28000+ rows, it leads to a memory error (and is time consuming)...
                • 4172
                • 5,888 Posts
                you can try this:

                $c=$modx->newQuery('Mytable');
                $c->select('id');
                $nbrows = $modx->getCount('Mytable', $c);
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                • Just use
                  $nbrows = $modx->getCount('Mytable');
                  and you’re done. You can’t use select() with getCount() because it uses it’s own custom "select" and ignores any you provide.
                    • 11155
                    • 74 Posts
                    Thanks... it is *somewhat* working !? -> it doesn’t work on the table I need, but it works on any others ! Call it bad luck. I quickly checked the files generated my the famous CreateXpdoClasses snippet, the only difference I see is that the files corresponding to tables that work contain code like this:
                    <?php
                    class ThisTableWorks extends xPDOSimpleObject {}

                    and the file corresponding to the only table that I really need and the only one that deosn’t work is this:
                    <?php
                    class ThisTableDoesNotWork extends xPDOObject {}


                    And can anyone answer the initial question (not from me) ?

                    Quote from: charliez at Oct 28, 2010, 06:55 PM

                    does the following has to be run every single time? or just at the beginning...

                    $path = MODX_CORE_PATH . 'components/reader/';
                    $result = $modx->addPackage('reader',$path . 'model/','mxp_');

                    • Well, it won’t work if there is no primary key defined for the table, but otherwise, it should work.