PHP » GoLang |
login |
register |
about
|
GoLang MongoDB::command
request it (531)
GoLang replacement for PHP's MongoDB::command
[edit | history]
MongoDB::command(PECL mongo >=0.9.2) MongoDB::command — Execute a database command Description
public array MongoDB::command
( array
$command
[, array $options = array()
[, string &$hash
]] )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 Parameters
Changelog
Return ValuesReturns database response. Every database response is always maximum one document, which means that the result of a database command can never exceed 16MB. The resulting document's structure depends on the command, but most results will have the ok field to indicate success or failure and results containing an array of each of the resulting documents. ExamplesExample #1 MongoDB::command() "distinct" example Finding all of the distinct values for a key.
<?php The above example will output something similar to: 4 22 87 Example #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 The above example will output something similar to: 22 87 Example #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 The above example will output something similar to: User 47cc67093475061e3d9536d2 had 3 sale(s). User 49902cde5162504500b45c2c had 14 sale(s). User 4af467e4fd543cce7b0ea8e2 had 1 sale(s).
Example #4 MongoDB::command() "geoNear" example This example shows how to use the geoNear command.
<?php See Also
MongoDB core docs on » database commands. |
more
Recently updated
more
Most requested
more
Last requests
|