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

    I am trying to filter multiple records on a field that has an alias
    See below example.

    $select2 = $modx->newQuery('Accomodations');
    	$select2->select(array(
    		'Accomodations.id',
    		'Accomodations.naam as Acconaam',
    		'Accomodations.vanafPrijs',
    		'Accomodations.thumbnail',
    		'Accomodations.alias as accoAlias',
    		'Countries.id as cID', //<- this field
    		'Countries.naam as landNaam',
    		'Countries.alias',
    		'Countries.vluchtprijs',
    		'Accomodations.klasse',
    		));
    		
    		$select2->where(array(
    		'Accomodations.active' => '1',
    		'Countries.id:!=' => $cid,
    		'Accomodations.klasse:=' => number_format($sterren, 2), 
    		));
    		
    		$select2->orCondition(array( 'cID:!=' => '9'));
    		$select2->orCondition(array( 'cID:!=' => '34'));
    		$select2->orCondition(array( 'cID:!=' => '35'));
    		$select2->orCondition(array( 'cID:!=' => '38'));
    		$select2->orCondition(array( 'cID:!=' => '40'));
    		$select2->orCondition(array( 'cID:!=' => '39'));
    


    This is part of an automated slection of hotel combination, i want to filter on some countries that cannot be combined with eachother.

    First off, is the orCondition way the proper way to do this, or is there a simpler way?
    Secondly, the filter is not working this way. Propably because of the alias on the Countries.id field, but i don't really know how to tell to select on that field.

    Anyone that does know what is going wrong?