Hi all i'm struggling wit this.
i need to get some resources where the template = 4
AND
a keyword is in either the pagetitle OR the page content
this does not seem to work (code is simplified)
$criteria = $modx->newQuery('modResource');
$criteria->where(array('published' => 1,
'template' => 4,
'deleted' => 0
),xPDOQuery::SQL_AND);
if(isset($_POST["keyword"]) && $_POST["keyword"] != ''){
$criteria->where(array('modResource.content:LIKE' => '%' . $_POST["keyword"] . '%'),xPDOQuery::SQL_OR);
$criteria->where(array('modResource.pagetitle:LIKE' => '%' . $_POST["keyword"] . '%'),xPDOQuery::SQL_OR);
}
$criteria->sortby('menuindex', 'ASC');
$docArray = $modx->getCollection('modResource', $criteria);
because it gives me a resource where the keyword is correct but the template != 4
how can i combine the 2 OR statements?
to get something like this
SELECT * FROM modResource
WHERE Template='4'
AND (pagetitle LIKE %'$keyword'% OR content LIKE %'$keyword'%);
thanks for the help
Rdg