|
MongoDB::command(PECL mongo >=0.9.2) MongoDB::command — Execute a database command Описание
public array MongoDB::command
( array $command
[, array $options = array()
] )
Almost everything that is not a CRUD operation can be done with a database command. Need to know the database version? There's a command for that. Need to do aggregation? There's a command for that. Need to turn up logging? You get the idea. This method is identical to:
<?php Список параметров
Список изменений
Возвращаемые значенияReturns database response. ПримерыПример #1 MongoDB::command() "distinct" example Finding all of the distinct values for a key.
<?php Результатом выполнения данного примера будет что-то подобное: 4 22 87 Пример #2 MongoDB::command() "distinct" example Finding all of the distinct values for a key, where the value is larger than or equal to 18.
<?php Результатом выполнения данного примера будет что-то подобное: 22 87 Пример #3 MongoDB::command() MapReduce example Get all users with at least on "sale" event, and how many times each of these users has had a sale.
<?php Результатом выполнения данного примера будет что-то подобное: User 47cc67093475061e3d9536d2 had 3 sale(s). User 49902cde5162504500b45c2c had 14 sale(s). User 4af467e4fd543cce7b0ea8e2 had 1 sale(s).
If you are going to be using MapReduce, Prajwal Tuladhar created an API for Mongo PHP users which provides a nicer interface than the bare command. You can download it from » Github and there is a » blog post on how to use it. Смотрите такжеMongoDB core docs on » database commands and on individual commands: » findAndModify, » getLastError, and » repair (dozens more exist, there are merely a few examples). |
|||||