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

    When trying to use a custom query hook I'm getting the following error:

    [2014-01-02 12:49:25] (ERROR in xPDO::getCount @ /path/to/site/root/core/xpdo/xpdo.class.php : 1024) Error 42S02 executing statement:
    Array
    (
    [0] => 42S02
    [1] => 1146
    [2] => Table 'pmd_modx2210.pmdproperties' doesn't exist
    )

    I have a package called pmdproperties under core/components/ and the class is Pmdproperty.

    So in my custom query hook I have:

    $main = array(
        'package' => 'pmdproperties',
        'packagePath' => '{core_path}components/pmdproperties/model/',
        'class' => 'Pmdproperty',
        'fields' => 'thumbnail , address , location , price , propertytype , numbeds , coords , contract , featured , reduced', 
        'withFields' => 'address , location , propertytype , numbeds , contract , price', 
    );
    
    $andConditions = array(
        'Pmdproperty.propertytype:=' => 'propertyType:request:all',
        'Pmdproperty.numbeds:=' => 'beds:request:any',
        'Pmdproperty.contract:=' => 'forSale forRent',
        'Pmdproperty.price:>=' => 'inputPriceFrom,request,none',
        'Pmdproperty.price:>=' => 'inputPriceTo,request,none'
    );
    
    
    // set the query hook declaration
    $qhDeclaration = array(
        'qhVersion' => '1.2',
    	'main' => $main,
    	'andConditions' => $andConditions,
    );
    
    $hook->setQueryHook($qhDeclaration);
    
    return true;


    This seems right to me? Yet I'm getting the table doesn't exist error. Anyone who can shed any light?

    I have zend framework 1.12 set up in my assets/libraries/ folder too.

    Thanks in advance !!

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

      Twitter @alexmercenary
    • Despite having the package installed, can you confirm that the table does genuinely exist?
        • 38713
        • 91 Posts
        I can indeed. I have attached a screenshot just in case I am missing something.

        Thanks
          Twitter @alexmercenary
        • "[2] => Table 'pmd_modx2210.pmdproperties' doesn't exist"
          It should be "pmd_modx2210.modx_pmdproperties"
            Rico
            Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
            MODx is great, but knowing how to use it well makes it perfect!

            www.virtudraft.com

            Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

            Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

            Maintainter/contributor of Babel

            Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
            • 38713
            • 91 Posts
            Hi Goldsky!

            I did think that looked odd so i tried adding the prefix to the package value in the $main array of the query hook but it didn't work. Any thoughts?

            Thanks for getting back to me!
              Twitter @alexmercenary
            • discuss.answer
              • 38713
              • 91 Posts
              Ok...

              I've fixed this by adding 'tablePrefix' => 'modx_', to the $main array.

              I don't know why this has had to be added for the default prefix but it has fixed it, so to anyone else who may experience this. Add the modx prefix manually.

              Thanks.
                Twitter @alexmercenary