PHP Класс MongoCollection, horde

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$db MongoDB

Защищенные свойства (Protected)

Свойство Тип Описание
$collection MongoDB\Collection
$name string

Открытые методы

Метод Описание
__construct ( MongoDB $db, string $name ) Creates a new collection
__get ( string $name ) : MongoCollection Gets a collection
__set ( string $name, mixed $value )
__sleep ( ) : array
__toString ( ) : string String representation of this collection
aggregate ( array $pipeline, array $op = [] ) : array Perform an aggregation using the aggregation framework
aggregateCursor ( array $pipeline, array $options = [] ) : MongoCommandCursor Execute an aggregation pipeline command and retrieve results through a cursor
batchInsert ( array &$a, array $options = [] ) : mixed Inserts multiple documents into this collection
count ( array | stdClass $query = [], array $options = [] ) : integer Counts the number of documents in this collection
createDBRef ( array | object $document_or_id ) : array Creates a database reference
createIndex ( array $keys, array $options = [] ) : array Creates an index on the given field(s), or does nothing if the index already exists
deleteIndex ( string | array $keys ) : array Deletes an index from this collection
deleteIndexes ( ) : array Delete all indexes for this collection
distinct ( string $key, array $query = [] ) : array | boolean Retrieve a list of distinct values for the given key across a collection
drop ( ) : array Drops this collection
ensureIndex ( array $keys, array $options = [] ) : array Creates an index on the given field(s), or does nothing if the index already exists
find ( array $query = [], array $fields = [] ) : MongoCursor Querys this collection
findAndModify ( array $query, array $update = null, array $fields = null, array $options = [] ) : array Update a document and return it
findOne ( array $query = [], array $fields = [], array $options = [] ) : array | null Querys this collection, returning a single element
getCollection ( ) : MongoDB\Collection Gets the underlying collection for this object
getDBRef ( array $ref ) : array Fetches the document pointed to by a database reference
getIndexInfo ( ) : array Returns an array of index names for this collection
getName ( ) : string Returns this collection's name
group ( mixed $keys, array $initial, MongoCode | string $reduce, array $condition = [] ) : array Performs an operation similar to SQL's GROUP BY command
insert ( array | object &$a, array $options = [] ) : boolean | array Inserts an array into the collection
parallelCollectionScan ( integer $num_cursors ) : MongoCommandCursor[] Returns an array of cursors to iterator over a full collection in parallel
remove ( array $criteria = [], array $options = [] ) : boolean | array Remove records from this collection
save ( array | object &$a, array $options = [] ) : array | boolean Saves an object to this collection
setReadPreference ( $readPreference, $tags = null )
setWriteConcern ( $wstring, $wtimeout )
update ( array $criteria, array $newobj, array $options = [] ) : boolean Update records based on a given criteria
validate ( boolean $scan_data = FALSE ) : array Validates this collection

Защищенные методы

Метод Описание
notImplemented ( )

Приватные методы

Метод Описание
checkCollectionName ( $name )
convertWriteConcernOptions ( array $options ) : array Converts legacy write concern options to a WriteConcern object
createCollectionObject ( ) : MongoDB\Collection
ensureDocumentHasMongoId ( array | object &$document ) : MongoId

Описание методов

__construct() публичный Метод

Creates a new collection
public __construct ( MongoDB $db, string $name )
$db MongoDB Parent database.
$name string Name for this collection.

__get() публичный Метод

Gets a collection
public __get ( string $name ) : MongoCollection
$name string The next string in the collection name.
Результат MongoCollection

__set() публичный Метод

public __set ( string $name, mixed $value )
$name string
$value mixed

__sleep() публичный Метод

public __sleep ( ) : array
Результат array

__toString() публичный Метод

String representation of this collection
public __toString ( ) : string
Результат string Returns the full name of this collection.

aggregate() публичный Метод

Perform an aggregation using the aggregation framework
public aggregate ( array $pipeline, array $op = [] ) : array
$pipeline array
$op array
Результат array

aggregateCursor() публичный Метод

Execute an aggregation pipeline command and retrieve results through a cursor
public aggregateCursor ( array $pipeline, array $options = [] ) : MongoCommandCursor
$pipeline array
$options array
Результат MongoCommandCursor

batchInsert() публичный Метод

Inserts multiple documents into this collection
public batchInsert ( array &$a, array $options = [] ) : mixed
$a array An array of arrays.
$options array Options for the inserts.
Результат mixed If "safe" is set, returns an associative array with the status of the inserts ("ok") and any error that may have occured ("err"). Otherwise, returns TRUE if the batch insert was successfully sent, FALSE otherwise.

count() публичный Метод

Counts the number of documents in this collection
public count ( array | stdClass $query = [], array $options = [] ) : integer
$query array | stdClass
$options array
Результат integer Returns the number of documents matching the query.

createDBRef() публичный Метод

Creates a database reference
public createDBRef ( array | object $document_or_id ) : array
$document_or_id array | object Object to which to create a reference.
Результат array Returns a database reference array.

createIndex() публичный Метод

Creates an index on the given field(s), or does nothing if the index already exists
public createIndex ( array $keys, array $options = [] ) : array
$keys array Field or fields to use as index.
$options array [optional] This parameter is an associative array of the form array("optionname" => , ...).
Результат array Returns the database response.

deleteIndex() публичный Метод

Deletes an index from this collection
public deleteIndex ( string | array $keys ) : array
$keys string | array Field or fields from which to delete the index.
Результат array Returns the database response.

deleteIndexes() публичный Метод

Delete all indexes for this collection
public deleteIndexes ( ) : array
Результат array Returns the database response.

distinct() публичный Метод

Retrieve a list of distinct values for the given key across a collection
public distinct ( string $key, array $query = [] ) : array | boolean
$key string The key to use.
$query array An optional query parameters
Результат array | boolean Returns an array of distinct values, or FALSE on failure

drop() публичный Метод

Drops this collection
public drop ( ) : array
Результат array Returns the database response.

ensureIndex() публичный Метод

Creates an index on the given field(s), or does nothing if the index already exists
Устаревший: Use MongoCollection::createIndex() instead.
public ensureIndex ( array $keys, array $options = [] ) : array
$keys array Field or fields to use as index.
$options array [optional] This parameter is an associative array of the form array("optionname" => , ...).
Результат array Returns the database response.

find() публичный Метод

Querys this collection
public find ( array $query = [], array $fields = [] ) : MongoCursor
$query array The fields for which to search.
$fields array Fields of the results to return.
Результат MongoCursor

findAndModify() публичный Метод

Update a document and return it
public findAndModify ( array $query, array $update = null, array $fields = null, array $options = [] ) : array
$query array The query criteria to search for.
$update array The update criteria.
$fields array Optionally only return these fields.
$options array An array of options to apply, such as remove the match document from the DB and return it.
Результат array Returns the original document, or the modified document when new is set.

findOne() публичный Метод

Querys this collection, returning a single element
public findOne ( array $query = [], array $fields = [], array $options = [] ) : array | null
$query array The fields for which to search.
$fields array Fields of the results to return.
$options array
Результат array | null

getCollection() публичный Метод

Gets the underlying collection for this object
public getCollection ( ) : MongoDB\Collection
Результат MongoDB\Collection

getDBRef() публичный Метод

Fetches the document pointed to by a database reference
public getDBRef ( array $ref ) : array
$ref array A database reference.
Результат array Returns the database document pointed to by the reference.

getIndexInfo() публичный Метод

Returns an array of index names for this collection
public getIndexInfo ( ) : array
Результат array Returns a list of index names.

getName() публичный Метод

Returns this collection's name
public getName ( ) : string
Результат string

group() публичный Метод

Performs an operation similar to SQL's GROUP BY command
public group ( mixed $keys, array $initial, MongoCode | string $reduce, array $condition = [] ) : array
$keys mixed Fields to group by. If an array or non-code object is passed, it will be the key used to group results.
$initial array Initial value of the aggregation counter object.
$reduce MongoCode | string A function that aggregates (reduces) the objects iterated.
$condition array An condition that must be true for a row to be considered.
Результат array

insert() публичный Метод

Inserts an array into the collection
public insert ( array | object &$a, array $options = [] ) : boolean | array
$a array | object
$options array
Результат boolean | array Returns an array containing the status of the insertion if the "w" option is set.

notImplemented() защищенный Метод

protected notImplemented ( )

parallelCollectionScan() публичный Метод

Returns an array of cursors to iterator over a full collection in parallel
public parallelCollectionScan ( integer $num_cursors ) : MongoCommandCursor[]
$num_cursors integer The number of cursors to request from the server. Please note, that the server can return less cursors than you requested.
Результат MongoCommandCursor[]

remove() публичный Метод

Remove records from this collection
public remove ( array $criteria = [], array $options = [] ) : boolean | array
$criteria array Query criteria for the documents to delete.
$options array An array of options for the remove operation.
Результат boolean | array Returns an array containing the status of the removal if the "w" option is set. Otherwise, returns TRUE.

save() публичный Метод

Saves an object to this collection
public save ( array | object &$a, array $options = [] ) : array | boolean
$a array | object Array to save. If an object is used, it may not have protected or private properties.
$options array Options for the save.
Результат array | boolean If w was set, returns an array containing the status of the save. Otherwise, returns a boolean representing if the array was not empty (an empty array will not be inserted).

setReadPreference() публичный Метод

public setReadPreference ( $readPreference, $tags = null )

setWriteConcern() публичный Метод

public setWriteConcern ( $wstring, $wtimeout )

update() публичный Метод

Update records based on a given criteria
public update ( array $criteria, array $newobj, array $options = [] ) : boolean
$criteria array Description of the objects to update.
$newobj array The object with which to update the matching records.
$options array
Результат boolean

validate() публичный Метод

Validates this collection
public validate ( boolean $scan_data = FALSE ) : array
$scan_data boolean Only validate indices, not the base collection.
Результат array Returns the database's evaluation of this object.

Описание свойств

$collection защищенное свойство

protected Collection,MongoDB $collection
Результат MongoDB\Collection

$db публичное свойство

public MongoDB $db
Результат MongoDB

$name защищенное свойство

protected string $name
Результат string