Reputation: 223
I'm trying to exclude the _id field from PHP-MongoDB result.below is my PHP script.What I can add to the script to exclude _id from the output.
<?php
try
{
$connection = new Mongo('mongodb://user:[email protected]:xxxxx/stats');
$database = $connection->selectDB('stats');
$collection = $database->selectCollection('stat');
}
catch(MongoConnectionException $e)
{
die("Failed to connect to database ".$e->getMessage());
}
$cursor = $collection->find();
echo json_encode(iterator_to_array($cursor));
?>
Upvotes: 0
Views: 526