I want to get data from all documents that are in Collection. In my case the data is Color field. I want to retrieve all the Color fields values from all documents that are in the Collection. Is it possible using MongoManager class in PHP? I am trying in this way;
$mng = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDB\Driver\Query([]);
$r = $mng->executeQuery("DB.Collection", $query);
$R = current($r->toArray());
if (!empty($R)) {
echo ($R->Color);
} else {
echo "Nothing found";
}
But it gives only one field. How can I get all color fields?