string - How do I use a phrase with php in a mongo text search? -


i've got simple mongo query returns result want -

db.properties.findone({$text:{$search:'\"eiffel petit louvre\"'}}) 

however can't seem transpose same query php -

$searchstring = '\"eiffel petit louvre\"'; $hotel = $db->properties->findone(         array('$text' => array('$search' => $searchstring)) ); 

this doesn't give me results back. doing wrong? i'm guessing it's string. i've tried escaping backslashes (i don't think should need since string uses single quotes), didn't work.

hi had exact same problem. after long trial , error figured out following works:

array('$text'=>array('$search'=>"\"$searchstring\"")) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -