12345678910111213141516171819 |
- <?php
- require_once("../../../mdb/vendor/autoload.php");
- use MongoDB\BSON\ObjectId;
- use MongoDB\Client;
- // Requires the MongoDB PHP Driver
- // https://www.mongodb.com/docs/drivers/php/
- $client = new Client('mongodb://kpadmin:AnandAyyappan1981@127.0.0.1:27017/?authSource=kpmaster');
- $collection = $client->selectCollection('kpmaster', 'kpu');
- //$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']]]);
- $updateResult = $collection->updateOne(
- [ '_id' => new ObjectId('64b0f61b8b3742ad72109e80') ],
- [ '$push' => [ 'srvs' => 'Running' ]]
- );
- printf("Matched %d document(s)\n", $updateResult->getMatchedCount());
- printf("Modified %d document(s)\n", $updateResult->getModifiedCount());
- ?>
|