1

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);
CyanCoding
  • 1,012
  • 1
  • 12
  • 35

2 Answers2

2

Try this,

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

more details, please check this out

Mahmudul Hasan
  • 126
  • 2
  • 6
0

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')))