(No version information available, might only be in Git)
CollectionFind::fields — Set document field filter
$projection
)This is the equivalent of the SQL projection, which allows to select which columns the query shall return.
projection
Can either be a single string or an array of string, those strings are identifying the columns that have to be returned for each document that match the search condition.
A CollectionFind object that can be used for further processing
Example #1 mysql_xdevapi\CollectionFind::fields() example
<?php
//Assuming $coll is a valid collection object
/*
The following find call will search for all the documents
with a 'job' like 'tassinaro' and will return only the column
'age' from each document
*/
$res = $coll->find('job like \'tassinaro\'')->fields('age')->execute();
//Example which make use of the COUNT function
$res = $coll->find()->fields(['COUNT(name) as cn', 'MAX(age) as ma', 'job as j'])->execute();
?>