Given: You have a functioning substring-search in a ZF2 model. How do you do turn that into a whole-word search?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
One method would be to use a MySQL REGEXP call in a Predicate Expression.
Where
$select
is an instance ofZend\Db\Sql\Select
and$searchFor
is your search term:The original substring search might use a where like this...
...and whole-word version of the above is:
Note these are multi-field searches, so I've done a
PredicateSet::COMBINED_BY_OR
. It took me far too long to stop fooling around with\b
in my regex. Hope this saves someone out there some time.