We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Why am I getting errors when trying to run this:

    if($queryFilters['status_id'] == '' ){$queryFilters['status_id'] = 2;} 
    $mygroups = $this->getGroupMemberships();
    $criteria = $this->modx->newQuery('FundRequest');
    $criteria->where($queryFilters);
    $criteria->andCondition(array('Program.location_id:IN' => $mygroups));
    $criteria->sortby('`FundRequest`.`request_date`','desc');
    
    $fundRequests = $this->modx->getCollectionGraph('FundRequest', '{ "StatusFlag":{}, "PaymentMethod":{}, "Contract":{ "Client": {}, }, "Program": { "Location": {}, } }', $criteria);
    
    $criteria->prepare();
    echo '<pre>'.$criteria->toSQL().'</pre>';


    I get a "Unknown column 'Program.location_id' in 'where clause'"

    If I run:

    echo $fundRequest->Program->Location->get('location').'<br>';


    Without the $criteria->andCondition(array('Program.location_id:IN' => $mygroups)); I get correct results, so I know the schema is correct.

    If I grab the sql output, I can see that the Program table has not been joined.

    What is the correct way of joining a table in the $criteria for a call to getCollectionGraph?
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525