PHP Class MongoCollection, horde

Afficher le fichier Open project: horde/horde Class Usage Examples

Méthodes publiques

Свойство Type Description
$db MongoDB

Protected Properties

Свойство Type Description
$collection MongoDB\Collection
$name string

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
notImplemented ( )

Private Methods

Méthode Description
checkCollectionName ( $name )
convertWriteConcernOptions ( array $options ) : array Converts legacy write concern options to a WriteConcern object
createCollectionObject ( ) : MongoDB\Collection
ensureDocumentHasMongoId ( array | object &$document ) : MongoId

Method Details

__construct() public méthode

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

__get() public méthode

Gets a collection
public __get ( string $name ) : MongoCollection
$name string The next string in the collection name.
Résultat MongoCollection

__set() public méthode

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

__sleep() public méthode

public __sleep ( ) : array
Résultat array

__toString() public méthode

String representation of this collection
public __toString ( ) : string
Résultat string Returns the full name of this collection.

aggregate() public méthode

Perform an aggregation using the aggregation framework
public aggregate ( array $pipeline, array $op = [] ) : array
$pipeline array
$op array
Résultat array

aggregateCursor() public méthode

Execute an aggregation pipeline command and retrieve results through a cursor
public aggregateCursor ( array $pipeline, array $options = [] ) : MongoCommandCursor
$pipeline array
$options array
Résultat MongoCommandCursor

batchInsert() public méthode

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.
Résultat 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() public méthode

Counts the number of documents in this collection
public count ( array | stdClass $query = [], array $options = [] ) : integer
$query array | stdClass
$options array
Résultat integer Returns the number of documents matching the query.

createDBRef() public méthode

Creates a database reference
public createDBRef ( array | object $document_or_id ) : array
$document_or_id array | object Object to which to create a reference.
Résultat array Returns a database reference array.

createIndex() public méthode

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" => , ...).
Résultat array Returns the database response.

deleteIndex() public méthode

Deletes an index from this collection
public deleteIndex ( string | array $keys ) : array
$keys string | array Field or fields from which to delete the index.
Résultat array Returns the database response.

deleteIndexes() public méthode

Delete all indexes for this collection
public deleteIndexes ( ) : array
Résultat array Returns the database response.

distinct() public méthode

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
Résultat array | boolean Returns an array of distinct values, or FALSE on failure

drop() public méthode

Drops this collection
public drop ( ) : array
Résultat array Returns the database response.

ensureIndex() public méthode

Creates an index on the given field(s), or does nothing if the index already exists
Deprecation: 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" => , ...).
Résultat array Returns the database response.

find() public méthode

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.
Résultat MongoCursor

findAndModify() public méthode

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.
Résultat array Returns the original document, or the modified document when new is set.

findOne() public méthode

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
Résultat array | null

getCollection() public méthode

Gets the underlying collection for this object
public getCollection ( ) : MongoDB\Collection
Résultat MongoDB\Collection

getDBRef() public méthode

Fetches the document pointed to by a database reference
public getDBRef ( array $ref ) : array
$ref array A database reference.
Résultat array Returns the database document pointed to by the reference.

getIndexInfo() public méthode

Returns an array of index names for this collection
public getIndexInfo ( ) : array
Résultat array Returns a list of index names.

getName() public méthode

Returns this collection's name
public getName ( ) : string
Résultat string

group() public méthode

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.
Résultat array

insert() public méthode

Inserts an array into the collection
public insert ( array | object &$a, array $options = [] ) : boolean | array
$a array | object
$options array
Résultat boolean | array Returns an array containing the status of the insertion if the "w" option is set.

notImplemented() protected méthode

protected notImplemented ( )

parallelCollectionScan() public méthode

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.
Résultat MongoCommandCursor[]

remove() public méthode

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.
Résultat boolean | array Returns an array containing the status of the removal if the "w" option is set. Otherwise, returns TRUE.

save() public méthode

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.
Résultat 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 méthode

public setReadPreference ( $readPreference, $tags = null )

setWriteConcern() public méthode

public setWriteConcern ( $wstring, $wtimeout )

update() public méthode

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
Résultat boolean

validate() public méthode

Validates this collection
public validate ( boolean $scan_data = FALSE ) : array
$scan_data boolean Only validate indices, not the base collection.
Résultat array Returns the database's evaluation of this object.

Property Details

$collection protected_oe property

protected Collection,MongoDB $collection
Résultat MongoDB\Collection

$db public_oe property

public MongoDB $db
Résultat MongoDB

$name protected_oe property

protected string $name
Résultat string