PHP Class PHPDaemon\Clients\Mongo\Pool

Author: Vasily Zorin ([email protected])
Inheritance: extends PHPDaemon\Network\Client, use trait PHPDaemon\Traits\StaticObjectWatchdog
Show file Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$cache Object of MemcacheClient
$collections Objects of MongoClientAsyncCollection
$dbname Current database
$lastRequestConnection Holds last used MongoClientAsyncConnection object

Protected Properties

Property Type Description
$safeMode

Public Methods

Method Description
__get ( string $name ) : Collection Magic getter-method. Proxy for getCollection
addServer ( string $url, integer $weight = null, mixed $mock = null ) : void Adds mongo server
aggregate ( array $p, callable $cb ) : void Aggregate function
auth ( array $p, callable $cb ) : void Sends authenciation packet
distinct ( array $p, callable $cb ) : void Returns distinct values of the property
ensureIndex ( string $ns, array $keys, array $options = [], callable $cb = null ) : void Ensure index
evaluate ( string $code, callable $cb ) : void Evaluates a code on the server side
find ( array $p, callable $cb ) : void Finds objects in collection
findAll ( array $p, callable $cb ) : void Finds objects in collection and fires callback when got all objects
findAndModify ( array $p, callable $cb ) : void Find and modify
findCount ( array $p, callable $cb ) : void Counts objects in collection
findOne ( array $p, callable $cb ) : void Finds one object in collection
getAuthKey ( string $username, string $password, string $nonce ) : string Generates auth. key
getCollection ( string $col ) : Collection Returns an object of collection
getIndexName ( array $keys ) : string
getMore ( string $col, string $id, integer $number, Connection $conn ) : void Asks for more objects
getNonce ( array $p, callable $cb ) : void Sends request of nonce
group ( array $p, callable $cb ) : void Groupping function
insert ( string $col, array $doc = [], callable $cb = null, array $params = [] ) : MongoId Inserts an object
insertMulti ( string $col, array $docs = [], callable $cb = null, array $params = [] ) : array Inserts several documents
killCursors ( array $cursors, Connection $conn ) : void Sends a request to kill certain cursors on the server side
lastError ( string $db, callable $cb, array $params = [], Connection $conn = null ) : void Gets last error
range ( array $p, callable $cb ) : void Find objects in collection using min/max specifiers
remove ( string $col, array $cond = [], callable $cb = null, array $params = [] ) : void Remove objects from collection
request ( integer $opcode, string $data, boolean $reply = false, Connection $conn = null, callable $sentcb = null ) : void Gets the key
safeModeEnc ( array &$o ) : void
saslScrumSHA1Auth ( $p, $cb )
saslScrumSHA1Conversation ( $dbname, $query, $cb, $conn = null )
saslScrumSHA1ExtractPayload ( $payload )
saslScrumSHA1Step ( $session, $input = null )
selectDB ( string $name ) : boolean Sets default database name
update ( string $col, array $cond, array $data, integer $flags, callable $cb = null, array $params = [] ) : void Updates one object in collection
updateMulti ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void Updates several objects in collection
updateOne ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void Updates one object in collection
upsert ( string $col, array $cond, array $data, boolean $multi = false, callable $cb = null, array $params = [] ) : void Upserts an object (updates if exists, insert if not exists)
upsertMulti ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void Upserts an object (updates if exists, insert if not exists)
upsertOne ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void Upserts an object (updates if exists, insert if not exists)

Protected Methods

Method Description
_paramFields ( mixed $f ) : array [_paramFields description]
_params ( &$p ) : void [_params description]
getConfigDefaults ( ) : array | boolean Setting default config options Overriden from AppInstance::getConfigDefaults
requestCbProducer ( integer $opcode, string $data, boolean $reply = false, callable $sentcb = null ) : callable

Method Details

__get() public method

Magic getter-method. Proxy for getCollection
public __get ( string $name ) : Collection
$name string Collection's name
return Collection

_paramFields() protected method

[_paramFields description]
protected _paramFields ( mixed $f ) : array
$f mixed
return array

_params() protected method

[_params description]
protected _params ( &$p ) : void
return void

addServer() public method

Adds mongo server
public addServer ( string $url, integer $weight = null, mixed $mock = null ) : void
$url string URL
$weight integer Weight
$mock mixed @deprecated
return void

aggregate() public method

Aggregate function
public aggregate ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, key, col)
$cb callable Callback called when response received
return void

auth() public method

Sends authenciation packet
public auth ( array $p, callable $cb ) : void
$p array Hash of properties (dbname, user, password, nonce)
$cb callable Callback called when response received
return void

distinct() public method

Returns distinct values of the property
public distinct ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, key, col, where)
$cb callable Callback called when response received
return void

ensureIndex() public method

Ensure index
public ensureIndex ( string $ns, array $keys, array $options = [], callable $cb = null ) : void
$ns string Collection
$keys array Keys
$options array Optional. Options
$cb callable Optional. Callback called when response received
return void

evaluate() public method

Evaluates a code on the server side
public evaluate ( string $code, callable $cb ) : void
$code string Code
$cb callable Callback called when response received
return void

find() public method

Finds objects in collection
public find ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, tailable, await, where, col, fields, sort, hint, explain, snapshot, orderby, parse_oplog)
$cb callable Callback called when response received
return void

findAll() public method

Finds objects in collection and fires callback when got all objects
public findAll ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, tailable, await, where, col, fields, sort, hint, explain, snapshot, orderby, parse_oplog)
$cb callable Callback called when response received
return void

findAndModify() public method

Find and modify
public findAndModify ( array $p, callable $cb ) : void
$p array Hash of properties
$cb callable Callback called when response received
return void

findCount() public method

Counts objects in collection
public findCount ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, where, col)
$cb callable Callback called when response received
return void

findOne() public method

Finds one object in collection
public findOne ( array $p, callable $cb ) : void
$p array Hash of properties (offset, opts, where, col, fields, sort, hint, explain, snapshot, orderby, parse_oplog)
$cb callable Callback called when response received
return void

getAuthKey() public static method

Generates auth. key
public static getAuthKey ( string $username, string $password, string $nonce ) : string
$username string Username
$password string Password
$nonce string Nonce
return string MD5 hash

getCollection() public method

Returns an object of collection
public getCollection ( string $col ) : Collection
$col string Collection's name
return Collection

getConfigDefaults() protected method

Setting default config options Overriden from AppInstance::getConfigDefaults
protected getConfigDefaults ( ) : array | boolean
return array | boolean

getIndexName() public method

public getIndexName ( array $keys ) : string
$keys array
return string

getMore() public method

Asks for more objects
public getMore ( string $col, string $id, integer $number, Connection $conn ) : void
$col string Collection's name
$id string Cursor's ID
$number integer Number of objects
$conn Connection Connection
return void

getNonce() public method

Sends request of nonce
public getNonce ( array $p, callable $cb ) : void
$p array Hash of properties
$cb callable Callback called when response received
return void

group() public method

Groupping function
public group ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, key, col, reduce, initial)
$cb callable Callback called when response received
return void

insert() public method

Inserts an object
public insert ( string $col, array $doc = [], callable $cb = null, array $params = [] ) : MongoId
$col string Collection's name
$doc array Document
$cb callable Optional. Callback
$params array Optional. Parameters
return MongoId

insertMulti() public method

Inserts several documents
public insertMulti ( string $col, array $docs = [], callable $cb = null, array $params = [] ) : array
$col string Collection's name
$docs array Array of docs
$cb callable Optional. Callback
$params array Optional. Parameters
return array IDs

killCursors() public method

Sends a request to kill certain cursors on the server side
public killCursors ( array $cursors, Connection $conn ) : void
$cursors array Array of cursors
$conn Connection Connection
return void

lastError() public method

Gets last error
public lastError ( string $db, callable $cb, array $params = [], Connection $conn = null ) : void
$db string Dbname
$cb callable Callback called when response received
$params array Parameters.
$conn Connection Connection. Optional
return void

range() public method

Find objects in collection using min/max specifiers
public range ( array $p, callable $cb ) : void
$p array Hash of properties (offset, limit, opts, where, col, min, max)
$cb callable Callback called when response received
return void

remove() public method

Remove objects from collection
public remove ( string $col, array $cond = [], callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$cb callable Optional. Callback called when response received
$params array Optional. Parameters
return void

request() public method

Gets the key
public request ( integer $opcode, string $data, boolean $reply = false, Connection $conn = null, callable $sentcb = null ) : void
$opcode integer Opcode (see constants above)
$data string Data
$reply boolean Is an answer expected?
$conn Connection Connection. Optional
$sentcb callable Sent callback
return void

requestCbProducer() protected method

protected requestCbProducer ( integer $opcode, string $data, boolean $reply = false, callable $sentcb = null ) : callable
$opcode integer Opcode (see constants above)
$data string Data
$reply boolean Is an answer expected?
$sentcb callable Sent callback
return callable

safeModeEnc() public static method

public static safeModeEnc ( array &$o ) : void
$o array
return void

saslScrumSHA1Auth() public method

public saslScrumSHA1Auth ( $p, $cb )

saslScrumSHA1Conversation() public method

public saslScrumSHA1Conversation ( $dbname, $query, $cb, $conn = null )

saslScrumSHA1ExtractPayload() public method

public saslScrumSHA1ExtractPayload ( $payload )

saslScrumSHA1Step() public method

public saslScrumSHA1Step ( $session, $input = null )

selectDB() public method

Sets default database name
public selectDB ( string $name ) : boolean
$name string Database name
return boolean Success

update() public method

Updates one object in collection
public update ( string $col, array $cond, array $data, integer $flags, callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$data array Data
$flags integer Optional. Flags
$cb callable Optional. Callback
$params array Optional. Parameters
return void

updateMulti() public method

Updates several objects in collection
public updateMulti ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$data array Data
$cb callable Optional. Callback
$params array Optional. Parameters
return void

updateOne() public method

Updates one object in collection
public updateOne ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$data array Data
$cb callable Optional. Callback
$params array Optional. Parameters
return void

upsert() public method

Upserts an object (updates if exists, insert if not exists)
public upsert ( string $col, array $cond, array $data, boolean $multi = false, callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$data array Data
$multi boolean Optional. Multi
$cb callable Optional. Callback
$params array Optional. Parameters
return void

upsertMulti() public method

Upserts an object (updates if exists, insert if not exists)
public upsertMulti ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$data array Data
$cb callable Optional. Callback
$params array Optional. Parameters
return void

upsertOne() public method

Upserts an object (updates if exists, insert if not exists)
public upsertOne ( string $col, array $cond, array $data, callable $cb = null, array $params = [] ) : void
$col string Collection's name
$cond array Conditions
$data array Data
$cb callable Optional. Callback
$params array Optional. Parameters
return void

Property Details

$cache public property

Object of MemcacheClient
public $cache

$collections public property

Objects of MongoClientAsyncCollection
public $collections

$dbname public property

Current database
public $dbname

$lastRequestConnection public property

Holds last used MongoClientAsyncConnection object
public $lastRequestConnection

$safeMode protected property

protected $safeMode