Today is hard day: I failed trying to open xPDO documentation page. Due to these circumstances I’m putting my problem here.
The following code (modified from resource/search processor):
$c = $modx->newQuery('modResource');
$where = array();
if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
$where['id'] = $_REQUEST['id'];
}
if (isset($_REQUEST['Szukaj']) && $_REQUEST['Szukaj'] != '') {
$where['pagetitle:LIKE'] = "%$szukaj%";
$where['longtitle:LIKE'] = "%$szukaj%";
$where['content:LIKE'] = "%$szukaj%";
}
if (isset($_REQUEST['published']) && $_REQUEST['published'] == 'on') {
$where['published'] = true;
}
if (isset($_REQUEST['unpublished']) && $_REQUEST['unpublished'] == 'on') {
$where['published'] = false;
}
if (isset($_REQUEST['deleted']) && $_REQUEST['deleted'] == 'on') {
$where['deleted'] = true;
}
if (isset($_REQUEST['undeleted']) && $_REQUEST['undeleted'] == 'on') {
$where['deleted'] = false;
}
$where['searchable'] = 1;
$c->where($where);
$c->where(array('content:LIKE'=>'koncepcja'));
$c->sortby($_REQUEST['sort'],$_REQUEST['dir']);
$c->limit($_REQUEST['limit'],$_REQUEST['start']);
produces following SQL query (ill just put a fragment which interests me the most):
... ` WHERE `modResource`.`pagetitle` LIKE '%koncepcja%' AND `modResource`.`longtitle` LIKE '%koncepcja%' AND `modResource`.`content` LIKE '%koncepcja%' AND `modResource`.`searchable` = 1 AND `modResource`.`OR content` LIKE '%koncepcja%' ORDER BY pagetitle ASC LIMIT 10
It searches for word ’koncepcja’ in pagetitle, longtitle, content. But it uses AND so search must satisfy all 3 conditions.
Instead of AND i would like to use OR.
Is it possible to do it with such syntax or i should use xPDOCriteria or sth?
--
Regards
MM