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);
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);
Try this,
$query = array("first_name" => array("$regex" => "/.a./"));
$updateResult = $this->dbCustomer->find($query);
I got an answer and I try this and it's work perfect :
$query = array(array("first_name" => new MongoDB\BSON\Regex("$search_text", 'i')))