mongo-php-library icon indicating copy to clipboard operation
mongo-php-library copied to clipboard

select certain field?

Open cenxun opened this issue 10 years ago • 2 comments

Does the current support select certain fields? just like Project Fields Such as SQL, select a, b, c

select a, b, c from x 

I see the Mongo client is supported, such as the following statement to return to the city field Db.zips.find ({'city': 1} {},.Limit) (1) Thank you for providing this library !

cenxun avatar Jun 28 '16 01:06 cenxun

Field projections are possible using the "projection" option on the MongoDB\Collection::find() and findOne() methods. See: http://mongodb.github.io/mongo-php-library/tutorial/crud/#query-projection for some examples.

If you are using the extension directly, you would specify this option in the second argument to MongoDB\Driver\Query::__construct().

jmikola avatar Jun 28 '16 19:06 jmikola

cool~ thanks.

cenxun avatar Jun 29 '16 01:06 cenxun