PHP Class Sokil\Mongo\Cursor

Inheritance: implements Iterator, implements Countable
Afficher le fichier Open project: sokil/php-mongo Class Usage Examples

Méthodes publiques

Méthode Description
__call ( $name, $arguments )
__construct ( Collection $collection, array $options = null )
asArray ( )
asObject ( )
byId ( string | MongoId $id ) : Cursor Filter by id
byIdList ( array $idList ) : Cursor Filter by list of \MongoId
copyToCollection ( type $targetCollectionName, type $targetDatabaseName = null ) Copy selected documents to another collection
count ( ) : integer Count documents in result without applying limit and offset
current ( )
explain ( )
expression ( ) : Expression Helper to create new expression
field ( string $field ) : Cursor Append field to accept list
fields ( array $fields ) : Cursor Return only specified fields
filter ( $handler )
findAll ( ) : array
findAndRemove ( ) : Document Get document instance and remove it from collection
findAndUpdate ( Operator $operator, boolean $upsert = false, boolean $returnUpdated = true ) : null | Document Find first document and update it
findOne ( ) : Document | array | null Find one document which correspond to expression
findRandom ( ) Get random document
getExpression ( ) : Expression Get query builder's expression
getHash ( ) Used to get hash that uniquely identifies current query
getIdList ( ) : array Gte list of \MongoId of current search query
getMongoQuery ( ) : array Get MongoDB query array
getOption ( string | integer $name, $default = null ) : mixed Get option
getReadPreference ( )
getResultSet ( ) : Sokil\Mongo\ResultSet Get result set of documents.
hint ( array | string $specification ) : Cursor Specify index to use
isDocumentPoolUsed ( )
isResultAsArray ( ) : boolean Check if result returned as array
key ( )
limit ( integer $limit, integer | null $offset = null ) : Cursor Limit result set to specified number of elements
limitedCount ( ) : integer Count documents in result with applying limit and offset
map ( $handler )
mixedToMongoIdList ( array $list ) : array Get list of MongoId objects from array of strings, MongoId's and Document's
moveToCollection ( type $targetCollectionName, type $targetDatabaseName = null ) Move selected documents to another collection.
next ( )
paginate ( integer $page, integer $itemsOnPage = 30 ) : Sokil\Mongo\Paginator Get paginator
pluck ( string $fieldName ) : array Return the values from a single field in the result set of documents
query ( Expression $expression ) : Cursor Merge expression
readNearest ( array $tags = null )
readPrimaryOnly ( )
readPrimaryPreferred ( array $tags = null )
readSecondaryOnly ( array $tags = null )
readSecondaryPreferred ( array $tags = null )
rewind ( )
setBatchSize ( integer $size ) : Cursor Specifies the number of documents to return in each batch of the response from the MongoDB instance.
setClientTimeout ( type $ms ) : Cursor Instructs the driver to stop waiting for a response and throw a MongoCursorTimeoutException after a set time, A timeout can be set at any time and will affect subsequent queries on the cursor, including fetching more results from the database.
setServerTimeout ( type $ms ) : Cursor Server-side timeout for a query, Specifies a cumulative time limit in milliseconds to be allowed by the server for processing operations on the cursor.
skip ( integer $skip ) : Cursor Skip defined number of documents
skipDocumentPool ( )
skipField ( string $field ) : Cursor Append field to skip list
skipFields ( array $fields ) : Cursor Return all fields except specified
slice ( string $field, integer $limit, integer $skip = null ) : Cursor Paginate list of sub-documents
sort ( array $sort ) : Cursor Sort result by specified keys and directions
useDocumentPool ( )
valid ( )

Private Methods

Méthode Description
getCursor ( ) : MongoCursor
pluckDotNoteted ( string $fieldName ) : array Pluck by dot-notated field name

Method Details

__call() public méthode

public __call ( $name, $arguments )

__construct() public méthode

public __construct ( Collection $collection, array $options = null )
$collection Collection
$options array

asArray() public méthode

public asArray ( )

asObject() public méthode

public asObject ( )

byId() public méthode

Filter by id
public byId ( string | MongoId $id ) : Cursor
$id string | MongoId id of document
Résultat Cursor

byIdList() public méthode

Filter by list of \MongoId
public byIdList ( array $idList ) : Cursor
$idList array list of ids
Résultat Cursor

copyToCollection() public méthode

Copy selected documents to another collection
public copyToCollection ( type $targetCollectionName, type $targetDatabaseName = null )
$targetCollectionName type
$targetDatabaseName type Target database name. If not specified - use current

count() public méthode

Count documents in result without applying limit and offset
public count ( ) : integer
Résultat integer count

current() public méthode

public current ( )

explain() public méthode

public explain ( )

expression() public méthode

Helper to create new expression
public expression ( ) : Expression
Résultat Expression

field() public méthode

Append field to accept list
public field ( string $field ) : Cursor
$field string field name
Résultat Cursor

fields() public méthode

Return only specified fields
public fields ( array $fields ) : Cursor
$fields array
Résultat Cursor

filter() public méthode

public filter ( $handler )

findAll() public méthode

public findAll ( ) : array
Résultat array result of searching

findAndRemove() public méthode

Get document instance and remove it from collection
public findAndRemove ( ) : Document
Résultat Document

findAndUpdate() public méthode

Find first document and update it
public findAndUpdate ( Operator $operator, boolean $upsert = false, boolean $returnUpdated = true ) : null | Document
$operator Operator operations with document to update
$upsert boolean if document not found - create
$returnUpdated boolean if true - return updated document
Résultat null | Document

findOne() public méthode

Find one document which correspond to expression
public findOne ( ) : Document | array | null
Résultat Document | array | null

findRandom() public méthode

Get random document
public findRandom ( )

getExpression() public méthode

Get query builder's expression
public getExpression ( ) : Expression
Résultat Expression

getHash() public méthode

Used to get hash that uniquely identifies current query
public getHash ( )

getIdList() public méthode

Gte list of \MongoId of current search query
public getIdList ( ) : array
Résultat array

getMongoQuery() public méthode

Get MongoDB query array
public getMongoQuery ( ) : array
Résultat array

getOption() public méthode

Get option
public getOption ( string | integer $name, $default = null ) : mixed
$name string | integer
Résultat mixed

getReadPreference() public méthode

public getReadPreference ( )

getResultSet() public méthode

Get result set of documents.
public getResultSet ( ) : Sokil\Mongo\ResultSet
Résultat Sokil\Mongo\ResultSet

hint() public méthode

Specify index to use
public hint ( array | string $specification ) : Cursor
$specification array | string Specify the index either by the index name or by document
Résultat Cursor

isDocumentPoolUsed() public méthode

public isDocumentPoolUsed ( )

isResultAsArray() public méthode

Check if result returned as array
public isResultAsArray ( ) : boolean
Résultat boolean

key() public méthode

public key ( )

limit() public méthode

Limit result set to specified number of elements
public limit ( integer $limit, integer | null $offset = null ) : Cursor
$limit integer number of elements in result set
$offset integer | null number of elements to skip
Résultat Cursor

limitedCount() public méthode

Count documents in result with applying limit and offset
public limitedCount ( ) : integer
Résultat integer count

map() public méthode

public map ( $handler )

mixedToMongoIdList() public static méthode

Get list of MongoId objects from array of strings, MongoId's and Document's
public static mixedToMongoIdList ( array $list ) : array
$list array
Résultat array list of \MongoId

moveToCollection() public méthode

Dociuments will be removed from source collection only after copying them to target collection.
public moveToCollection ( type $targetCollectionName, type $targetDatabaseName = null )
$targetCollectionName type
$targetDatabaseName type Target database name. If not specified - use current

next() public méthode

public next ( )

paginate() public méthode

Get paginator
public paginate ( integer $page, integer $itemsOnPage = 30 ) : Sokil\Mongo\Paginator
$page integer page number
$itemsOnPage integer number of items on page
Résultat Sokil\Mongo\Paginator

pluck() public méthode

Return the values from a single field in the result set of documents
public pluck ( string $fieldName ) : array
$fieldName string
Résultat array

query() public méthode

Merge expression
public query ( Expression $expression ) : Cursor
$expression Expression
Résultat Cursor

readNearest() public méthode

public readNearest ( array $tags = null )
$tags array

readPrimaryOnly() public méthode

public readPrimaryOnly ( )

readPrimaryPreferred() public méthode

public readPrimaryPreferred ( array $tags = null )
$tags array

readSecondaryOnly() public méthode

public readSecondaryOnly ( array $tags = null )
$tags array

readSecondaryPreferred() public méthode

public readSecondaryPreferred ( array $tags = null )
$tags array

rewind() public méthode

public rewind ( )

setBatchSize() public méthode

Specifies the number of documents to return in each batch of the response from the MongoDB instance.
public setBatchSize ( integer $size ) : Cursor
$size integer number of documents
Résultat Cursor

setClientTimeout() public méthode

Instructs the driver to stop waiting for a response and throw a MongoCursorTimeoutException after a set time, A timeout can be set at any time and will affect subsequent queries on the cursor, including fetching more results from the database.
public setClientTimeout ( type $ms ) : Cursor
$ms type
Résultat Cursor

setServerTimeout() public méthode

Server-side timeout for a query, Specifies a cumulative time limit in milliseconds to be allowed by the server for processing operations on the cursor.
public setServerTimeout ( type $ms ) : Cursor
$ms type
Résultat Cursor

skip() public méthode

Skip defined number of documents
public skip ( integer $skip ) : Cursor
$skip integer number of documents to skip
Résultat Cursor

skipDocumentPool() public méthode

public skipDocumentPool ( )

skipField() public méthode

Append field to skip list
public skipField ( string $field ) : Cursor
$field string field name
Résultat Cursor

skipFields() public méthode

Return all fields except specified
public skipFields ( array $fields ) : Cursor
$fields array
Résultat Cursor

slice() public méthode

Paginate list of sub-documents
public slice ( string $field, integer $limit, integer $skip = null ) : Cursor
$field string
$limit integer
$skip integer
Résultat Cursor

sort() public méthode

An array of fields by which to sort. Each element in the array has as key the field name, and as value either 1 for ascending sort, or -1 for descending sort. Each result is first sorted on the first field in the array, then (if it exists) on the second field in the array, etc. This means that the order of the fields in the fields array is important. See also the examples section.
public sort ( array $sort ) : Cursor
$sort array
Résultat Cursor

useDocumentPool() public méthode

public useDocumentPool ( )

valid() public méthode

public valid ( )