PHP Class Sokil\Mongo\Database

Show file Open project: sokil/php-mongo Class Usage Examples

Public Methods

Method Description
__construct ( Client $client, MongoDB | string $database )
__get ( $name )
authenticate ( string $username, string $password )
clearCollectionPool ( )
createCappedCollection ( string $name, integer $maxElements, integer $size ) : Collection
createCollection ( string $name, array $options = null ) : Collection Create collection
disableCollectionPool ( )
disableProfiler ( )
enableCollectionPool ( )
executeCommand ( array $command, array $options = [] ) : array Execute Mongo command
executeJS ( $code, array $args = [] )
findProfilerRows ( ) : Cursor
getCache ( string $namespace ) : Cache Get cache
getClient ( ) : Client
getCollection ( string $name ) : Collection
getDocumentByReference ( array $ref, boolean $useDocumentPool = true ) : Document | null Get Document instance by it's reference
getGridFS ( string $name = 'fs' ) : GridFS Get instance of GridFS
getLastError ( )
getMongoDB ( ) : MongoDB
getName ( ) : string
getProfilerLevel ( )
getProfilerParams ( )
getProfilerSlowMs ( )
getQueue ( string $channel ) : Queue
getReadPreference ( )
getWriteConcern ( ) : mixed Get current write concern May be used only if mongo extension version >=1.5
isCollectionPoolEmpty ( )
isCollectionPoolEnabled ( )
logout ( )
map ( string | array $name, string | array | Definition | null $classDefinition = null ) : Client Map collection name to class
profileAllQueries ( $slowms = null )
profileSlowQueries ( $slowms = 100 )
readNearest ( array $tags = null )
readPrimaryOnly ( )
readPrimaryPreferred ( array $tags = null )
readSecondaryOnly ( array $tags = null )
readSecondaryPreferred ( array $tags = null )
resetMapping ( ) : Client Reset specified mapping
setMajorityWriteConcern ( integer $timeout = 10000 ) : Database Define majority write concern.
setUnacknowledgedWriteConcern ( integer $timeout = 10000 ) : Database Define unacknowledged write concern.
setWriteConcern ( string | integer $w, integer $timeout = 10000 ) : Database Define write concern.
stats ( )

Private Methods

Method Description
defineCollection ( string $name, Definition | array | string $definition ) : Database Define collection through array or Definition instance
getCollectionDefinition ( string $name, array $defaultDefinition = null ) : string | array Get class name mapped to collection

Method Details

__construct() public method

public __construct ( Client $client, MongoDB | string $database )
$client Client
$database MongoDB | string

__get() public method

public __get ( $name )

authenticate() public method

public authenticate ( string $username, string $password )
$username string
$password string

clearCollectionPool() public method

public clearCollectionPool ( )

createCappedCollection() public method

public createCappedCollection ( string $name, integer $maxElements, integer $size ) : Collection
$name string name of collection
$maxElements integer The maximum number of elements to store in the collection.
$size integer Size in bytes.
return Collection

createCollection() public method

Create collection
public createCollection ( string $name, array $options = null ) : Collection
$name string name of collection
$options array array of options
return Collection

disableCollectionPool() public method

disableProfiler() public method

public disableProfiler ( )

enableCollectionPool() public method

executeCommand() public method

Execute Mongo command
public executeCommand ( array $command, array $options = [] ) : array
$command array
$options array
return array

executeJS() public method

public executeJS ( $code, array $args = [] )
$args array

findProfilerRows() public method

public findProfilerRows ( ) : Cursor
return Cursor

getCache() public method

Get cache
public getCache ( string $namespace ) : Cache
$namespace string
return Cache

getClient() public method

public getClient ( ) : Client
return Client

getCollection() public method

public getCollection ( string $name ) : Collection
$name string name of collection
return Collection

getDocumentByReference() public method

Get Document instance by it's reference
public getDocumentByReference ( array $ref, boolean $useDocumentPool = true ) : Document | null
$ref array reference to document
$useDocumentPool boolean try to get document from pool or fetch document from database
return Document | null

getGridFS() public method

Get instance of GridFS
public getGridFS ( string $name = 'fs' ) : GridFS
$name string prefix of files and chunks collection
return GridFS

getLastError() public method

public getLastError ( )

getMongoDB() public method

public getMongoDB ( ) : MongoDB
return MongoDB

getName() public method

public getName ( ) : string
return string get name of database

getProfilerLevel() public method

public getProfilerLevel ( )

getProfilerParams() public method

public getProfilerParams ( )

getProfilerSlowMs() public method

public getProfilerSlowMs ( )

getQueue() public method

public getQueue ( string $channel ) : Queue
$channel string name of channel
return Queue

getReadPreference() public method

public getReadPreference ( )

getWriteConcern() public method

Get current write concern May be used only if mongo extension version >=1.5
public getWriteConcern ( ) : mixed
return mixed

isCollectionPoolEmpty() public method

isCollectionPoolEnabled() public method

logout() public method

public logout ( )

map() public method

Map collection name to class
public map ( string | array $name, string | array | Definition | null $classDefinition = null ) : Client
$name string | array collection name or array like [collectionName => collectionClass, ...]
$classDefinition string | array | Sokil\Mongo\Collection\Definition | null if $name is string, then full class name or array with parameters, else omitted
return Client

profileAllQueries() public method

public profileAllQueries ( $slowms = null )

profileSlowQueries() public method

public profileSlowQueries ( $slowms = 100 )

readNearest() public method

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

readPrimaryOnly() public method

public readPrimaryOnly ( )

readPrimaryPreferred() public method

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

readSecondaryOnly() public method

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

readSecondaryPreferred() public method

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

resetMapping() public method

Reset specified mapping
public resetMapping ( ) : Client
return Client

setMajorityWriteConcern() public method

May be used only if mongo extension version >=1.5
public setMajorityWriteConcern ( integer $timeout = 10000 ) : Database
$timeout integer timeout in milliseconds
return Database

setUnacknowledgedWriteConcern() public method

May be used only if mongo extension version >=1.5
public setUnacknowledgedWriteConcern ( integer $timeout = 10000 ) : Database
$timeout integer timeout in milliseconds
return Database

setWriteConcern() public method

May be used only if mongo extension version >=1.5
public setWriteConcern ( string | integer $w, integer $timeout = 10000 ) : Database
$w string | integer write concern
$timeout integer timeout in milliseconds
return Database

stats() public method

public stats ( )