PHP Query in MongoDB doesn't work -
i have been trying fix problem since days , can't solve it.
i'm trying use mongo db first time , here's problem:
$id = utf8_encode($_post['mongo']); $query=array("id" => $id); $conn = new mongo("mongodb://localhost:27017"); $database = $conn->test; $collection = $database->pages; $doc = $collection->findone($query);
the $id
variable set 2, findone
doesn't return anything.
if try example change id
value in array 2 [$query=array("id" => 2);]
db returns document need.
it's mystery ahah.
can see error?
thanks
l
after connect should select document
$id = utf8_encode($_post['mongo']); $query=array("id" => $id); $m = new mongoclient('mongodb://localhost:27017'); $db = $m->selectdb('yourdocumentname'); $collection = new mongocollection($db, 'yourcollectionname'); $doc = $collection->findone($query); var_dump($doc);
Comments
Post a Comment