Search like % with Phalcon and Mongo DB
/**
* Get condition to query
* @param type $searchKey
*/
private function _conditions($searchKey) {
$string = preg_replace('/\s+/', '|', $searchKey);
$condition = ['$or' => [
['Question' => ['$regex' => "($string)", '$options' => 'i']],
['Content' => ['$regex' => "($string)", '$options' => 'i']]
]];
return $condition;
}
No comments:
Post a Comment