XF 2.2 How to write this query in a finder

Orit

Active member
Hi, I can't manage to get the finder to fetch this query:
SELECT * from xf_table where xf_table.title LIKE '%test%'

$formFinder->where('title', 'LIKE', $title) does not get the requested results.


Thanks!
 
Well, of course it should simply be:
$formFinder->where('title', 'LIKE', '%'.$title.'%');
 
Kind of.

This is the approach we take elsewhere in XF:

PHP:
$formFinder->where('title', 'like', $formFinder->escapeLike($title, '%?%'))

This will ensure the $title input is escaped correctly.
 
Top Bottom