• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Using the finder with whereOr and where


Well-known member
I'm trying to create a finder that selects certain threads. One of the criteria is to only select nodeIds if viewable, then further eliminate selections using the other ->where statements.

My question is the ->whereOr appears to override the ->where conditions below it. I suspect I need another AND somewhere but I'm not able to determine the correct syntax.

$nodeRepo = $this->repository('XF:Node');
$nodes = $nodeRepo->getNodeList();
$nodeIds = $nodes->keys();

$conditions[] = ['node_id', $nodeIds];

$finder = \XF::finder('XF:Thread');
$results1 = $finder
    ->where('title', 'LIKE', $searchWord1, '%?%')
    ->where('title', 'LIKE', $searchWord2, '%?%')
    ->where('title', 'LIKE', $searchWord3, '%?%')
    ->where('discussion_state', '=', 'visible')
    ->where('discussion_state', '<>', 'redirect')
    ->where('post_date', '>=', $gte)
    ->where('thread_id', '<>', $currentThreadId)
    ->order('post_date', 'DESC')
Thank you for your help.
Last edited:


Well-known member
The working query which I'm trying to replace is this:

$results1 = $db->fetchAll("
SELECT thread_id
FROM xf_thread
WHERE title LIKE ?
AND title LIKE ?
AND title LIKE ?
AND discussion_state = 'visible'
AND discussion_type <> 'redirect'
AND post_date >= ?
AND thread_id <> ?
AND (node_id = 1 OR node_id = 2)
ORDER BY post_date DESC
", array("%$searchWord1%", "%$searchWord2%", "%$searchWord3%", $gte, $currentThreadId, $maximumResults1));

Please note the following AND is an example only, normally there's a variable which contains all the viewable nodes.

AND (node_id = 1 OR node_id = 2)
Last edited:


Well-known member
We're getting back to people telling you to use a better IDE, or you don't understand what the IDE is telling you...

Try this...
$conditions = [['node_id', 1],['node_id', 2]];
If that works, it should be self explanatory what you did wrong or need to do (possibly in a different way).
Last edited:


Well-known member
Thank you for taking the time to look at this, Snog.

The original code I posted in post #1 works just fine, I was just tripped up on the $conditions variable being used later on.