Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda