index.php 985 B

12345678910111213141516171819
  1. <?php
  2. require_once("../../../mdb/vendor/autoload.php");
  3. use MongoDB\BSON\ObjectId;
  4. use MongoDB\Client;
  5. // Requires the MongoDB PHP Driver
  6. // https://www.mongodb.com/docs/drivers/php/
  7. $client = new Client('mongodb://kpadmin:AnandAyyappan1981@127.0.0.1:27017/?authSource=kpmaster');
  8. $collection = $client->selectCollection('kpmaster', 'kpu');
  9. //$cursor = $collection->aggregate([['$geoNear' => ['near' => ['type' => 'Point', 'coordinates' => [76.93, 8.52]], 'spherical' => true, 'query' => ['srvs' => ['$all' => ['Painting']]], 'distanceField' => 'Dis', 'maxDistance' => 2000, 'includeLocs' => 'loc']], ['$project' => ['ID'=>'$oid', 'Name' => '$fn', 'Distance' => '$Dis', 'Location' => '$loc']]]);
  10. $updateResult = $collection->updateOne(
  11. [ '_id' => new ObjectId('64b0f61b8b3742ad72109e80') ],
  12. [ '$pull' => [ 'srvs' => 'Washing' ]]
  13. );
  14. printf("Matched %d document(s)\n", $updateResult->getMatchedCount());
  15. printf("Modified %d document(s)\n", $updateResult->getModifiedCount());
  16. ?>