can i pass mongodb query as a string in php

前端 未结 1 749
[愿得一人]
[愿得一人] 2021-01-21 17:06

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\' =>          


        
相关标签:
1条回答
  • 2021-01-21 17:18

    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);
    
    0 讨论(0)
提交回复
热议问题