Skip to content

Instantly share code, notes, and snippets.

@diloabininyeri
Created September 23, 2020 22:59
Show Gist options
  • Select an option

  • Save diloabininyeri/a79293163646af99aacd2b70f595b226 to your computer and use it in GitHub Desktop.

Select an option

Save diloabininyeri/a79293163646af99aacd2b70f595b226 to your computer and use it in GitHub Desktop.
<?php
use MongoDB\Driver\Manager;
use MongoDB\Driver\Query;
$mongo =new Manager('mongodb://localhost/test');
$filter=array();
$id = new \MongoDB\BSON\ObjectId("5f6bcbecd518b66106059cc8");
$filter = ['_id' => $id];
$options = [];
$query = new Query($filter, $options);
$rows = $mongo->executeQuery('test.users', $query);
print_r($rows->toArray());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment