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

    Im trying to create a query like below using the xPDOQuery object, but im stuck, is this possible to do or do i need to write the SQL by hand an pass it to the object?

    SELECT `id` FROM `table` WHERE `published`='1' AND ( `parent` = '1' OR `parent`='2')


    Any help would be great!
    Thanks,
    Paul
      • 22934
      • 13 Posts
      Solved it myself i think, i did it this way if anyone else is interested (There is prob an easier way):

      $c= $modx->newQuery('modResource', 'web');
      $c->select('id');
      
      $c->where(array(
      	'`modResource`.parent' => 1,
      ));
      $c->orCondition(array(
      	'`modResource`.parent' => 2,
      ));
      $c->andCondition(array(
      	'`modResource`.published' => 1,
      	'`modResource`.context_key' => 'web',
      ));
      $collection = $modx->getCollection('modResource', $c);