skip to Main Content

I want to use like queries for search in my app using MongoDb With PHP but I did not get the proper result.

Code:

$query = array("first_name" => "/.*a.*/" );
$updateResult = $this->dbCustomer->find($query);

2

Answers


  1. Chosen as BEST ANSWER

    I got an answer and I try this and it's work perfect :

    $query = array(array("first_name" => new MongoDBBSONRegex("$search_text", 'i')))


  2. Try this,

    $query = array("first_name" => array("$regex" => "/.a./"));
    $updateResult = $this->dbCustomer->find($query);
    

    more details, please check this out

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search