Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
can i pass mongodb query as a string in php

I am planning to run mongodb query from php platform text area as picture below where I want to write query like

 array('Chat_time' => array('$gt' => $start, '$lte' => $end))

enter image description here

and execute like

$m = new MongoClient();
$db = $m->Forensic;
$coll= $db->mobile_
$user_code = $coll->find($_POST['txt_area']));

but cannot execute becuause I think when I convert query to string it cannot understand => as a command.

what would be the best way pass this command as a string and php will understand.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

you should write json to your text area. like:

{
    "Chat_time": {
        "$gt" => "xxx",
        "$lte" => "yyy"
    }
}

in php

// json string to array using json_decode
$query = json_decode($_POST['txt_area'], true);
$user_code = $coll->find($query);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!