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

    I have some issues in with a left join in an extended modObjectGetListProcessor. It doesn't seem to work and I don't really know where the issue is.
    I have taken over this project from an other developer which makes it somewhat complicated to find in the code, and just confusing.

    class NmcExportCompaniesListProcessor extends modObjectGetListProcessor {
     	public $classKey = 'nmcCompany';
     	//...
    
    	public function beforeQuery() {
    		$this->setProperty('limit', 0);
    		return true;
    	}
    
    	public function prepareQueryBeforeCount(xPDOQuery $c) {
    
    		$c->leftJoin('modUser','User',array('nmcCompany.main_user = User.id'));
    
    		return $c;
    	}
    
    	public function afterIteration(array $companies) {
    		
    		var_dump($companies); die;
    
    		return $companies;
    	}
    }
    


    This var_dumps the $companies array, but there is no joined User object.
    Do I need to do something else in the prepareRow method for this to work?

    I'm a total newbie on xPDO :/

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      I think, there needs to be a $c->select() with the User - fields somewhere.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • discuss.answer
        • 40706
        • 128 Posts
        Yes, the fields have to be selected.

        And should also xPDO::OPT_HYDRATE_ADHOC_FIELDS should be set or build within prepareRow() into the result array.
        http://rtfm.modx.com/xpdo/2.x/getting-started/fundamentals/xpdo,-the-class/the-xpdo-constructor/hydrating-fields