We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38878
    • 255 Posts
    I have a weird issue. I have two snippets access custom db classes. One retrieves the data just fine while the other gives me a fatal error accessing the same class:
    PHP Fatal error:  Call to undefined method OrganizationVendors_mysql::prepare() in /paas/c2356/www/core/xpdo/om/xpdoobject.class.php on line 233


    The relevant snippet code is:
    <?php
    $path = MODX_CORE_PATH . 'components/myComponent/';
    $result = $modx->addPackage('myComponent',$path . 'model/','mycomponent_');
    
    if (!$result) {
        $output = 'failed to load class';
    } else {
        $orgID = $modx->getOption('orgID', $scriptProperties);
        if ($debug) trigger_error($snippetname . " OrgID : " . $orgID, E_USER_ERROR);
        $orgVendors = $modx->getCollection('OrganizationVendors',array('organization' => $orgID));


    As you can see I am outputting the $orgID var so I know it is defined in both cases. Any ideas why would one snippet work fine and the other fail?
      • 44195
      • 293 Posts
      I know this is from a while ago, but what do you get if you make the getCollection call without specifying any properties?

      Also, can you show the snippet that works?
        I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
        Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com