PHP Class Alcaeus\MongoDbAdapter\AbstractCursor

Inheritance: use trait Alcaeus\MongoDbAdapter\Helper\ReadPreference
Show file Open project: alcaeus/mongo-php-adapter Class Usage Examples

Protected Properties

Property Type Description
$batchSize integer
$collection MongoDB\Collection
$connection MongoClient
$cursor MongoDB\Driver\Cursor
$cursorNeedsAdvancing boolean
$db MongoDB\Database
$iterator Iterator
$ns string
$optionNames array
$position integer
$startedIterating boolean

Public Methods

Method Description
__construct ( MongoClient $connection, string $ns ) Create a new cursor
__sleep ( ) : array
batchSize ( integer $batchSize ) Limits the number of elements returned in one batch.
current ( ) : array Returns the current element
dead ( ) : boolean Checks if there are documents that have not been sent yet from the database for this cursor
info ( ) : array
key ( ) : string Returns the current result's _id
next ( ) : array Advances the cursor to the next result, and returns that result
rewind ( ) : void Returns the cursor to the beginning of the result set
setReadPreference ( string $readPreference, array $tags = null )
timeout ( integer $ms ) Sets a client-side timeout for this query
valid ( ) : boolean Checks if the cursor is reading a valid result.

Protected Methods

Method Description
ensureCursor ( ) : MongoDB\Driver\Cursor
ensureIterator ( ) : Iterator
errorIfOpened ( )
getCursorInfo ( ) : array
getIterationInfo ( ) : array
getOptions ( array $optionNames = null ) : array Applies all options set on the cursor, overwriting any options that have already been set
notImplemented ( )
reset ( ) Clears the cursor
storeIteratorState ( ) Stores the current cursor element.
wrapTraversable ( Traversable $traversable ) : Generator

Method Details

__construct() public method

Create a new cursor
public __construct ( MongoClient $connection, string $ns )
$connection MongoClient Database connection.
$ns string Full name of database and collection.

__sleep() public method

public __sleep ( ) : array
return array

batchSize() public method

Limits the number of elements returned in one batch.
public batchSize ( integer $batchSize )
$batchSize integer The number of results to return per batch

current() public method

Returns the current element
public current ( ) : array
return array

dead() public method

Checks if there are documents that have not been sent yet from the database for this cursor
public dead ( ) : boolean
return boolean Returns if there are more results that have not been sent to the client, yet.

ensureCursor() abstract protected method

abstract protected ensureCursor ( ) : MongoDB\Driver\Cursor
return MongoDB\Driver\Cursor

ensureIterator() protected method

protected ensureIterator ( ) : Iterator
return Iterator

errorIfOpened() protected method

protected errorIfOpened ( )

getCursorInfo() abstract protected method

abstract protected getCursorInfo ( ) : array
return array

getIterationInfo() protected method

protected getIterationInfo ( ) : array
return array

getOptions() protected method

Applies all options set on the cursor, overwriting any options that have already been set
protected getOptions ( array $optionNames = null ) : array
$optionNames array Array of option names to be applied (will be read from properties)
return array

info() public method

public info ( ) : array
return array

key() public method

Returns the current result's _id
public key ( ) : string
return string The current result's _id as a string.

next() public method

Advances the cursor to the next result, and returns that result
public next ( ) : array
return array Returns the next object

notImplemented() protected method

protected notImplemented ( )

reset() protected method

This is generic but implemented as protected since it's only exposed in MongoCursor
protected reset ( )

rewind() public method

Returns the cursor to the beginning of the result set
public rewind ( ) : void
return void

setReadPreference() public method

public setReadPreference ( string $readPreference, array $tags = null )
$readPreference string
$tags array

storeIteratorState() protected method

This is necessary because hasNext() might advance the iterator but we still need to be able to return the current object.
protected storeIteratorState ( )

timeout() public method

Sets a client-side timeout for this query
public timeout ( integer $ms )
$ms integer The number of milliseconds for the cursor to wait for a response. By default, the cursor will wait forever.

valid() public method

Checks if the cursor is reading a valid result.
public valid ( ) : boolean
return boolean If the current result is not null.

wrapTraversable() protected method

protected wrapTraversable ( Traversable $traversable ) : Generator
$traversable Traversable
return Generator

Property Details

$batchSize protected property

protected int $batchSize
return integer

$collection protected property

protected Collection,MongoDB $collection
return MongoDB\Collection

$connection protected property

protected MongoClient $connection
return MongoClient

$cursor protected property

protected Cursor,MongoDB\Driver $cursor
return MongoDB\Driver\Cursor

$cursorNeedsAdvancing protected property

protected bool $cursorNeedsAdvancing
return boolean

$db protected property

protected Database,MongoDB $db
return MongoDB\Database

$iterator protected property

protected Iterator $iterator
return Iterator

$ns protected property

protected string $ns
return string

$optionNames protected property

protected array $optionNames
return array

$position protected property

protected int $position
return integer

$startedIterating protected property

protected bool $startedIterating
return boolean