index.php 479 B

123456789101112
  1. <?php
  2. require_once("./vendor/autoload.php");
  3. use MongoDB\Client;
  4. $client = new Client('mongodb://kpadmin:AnandAyyappan1981@127.0.0.1:27017/?authSource=kpmaster');
  5. $collection = $client->selectCollection('kpmaster', 'kpu');
  6. $cursor = $collection->find(['location' => ['$geoWithin' => ['$centerSphere' => [[76.93414657, 8.82302903], 500 / 3963.2]]]]);
  7. // foreach ($cursor as $document) {
  8. // echo $document["_id"] . "\n";
  9. // }
  10. echo json_encode(iterator_to_array($cursor));
  11. ?>