PHP Class Doctrine\MongoDB\Connection

Since: 1.0
Author: Jonathan H. Wage ([email protected])
Afficher le fichier Open project: doctrine/mongodb Class Usage Examples

Protected Properties

Свойство Type Description
$config Doctrine\MongoDB\Configuration The Configuration for this connection.
$driverOptions array Driver options used to construct the MongoClient instance (optional).
$eventManager Doctrine\Common\EventManager The EventManager used to dispatch events.
$mongoClient MongoClient The PHP MongoClient instance being wrapped.
$options array Options used to construct the MongoClient instance (optional).
$server string Server string used to construct the MongoClient instance (optional).

Méthodes publiques

Méthode Description
__construct ( string | MongoClient $server = null, array $options = [], Doctrine\MongoDB\Configuration $config = null, Doctrine\Common\EventManager $evm = null, array $driverOptions = [] ) Constructor.
__get ( string $database ) : MongoDB Wrapper method for MongoClient::__get().
__toString ( ) : string Wrapper method for MongoClient::__toString().
close ( ) : boolean Wrapper method for MongoClient::close().
connect ( ) : boolean Wrapper method for MongoClient::connect().
dropDatabase ( string $database ) : array Wrapper method for MongoClient::dropDB().
getConfiguration ( ) : Doctrine\MongoDB\Configuration Get the Configuration used by this Connection.
getEventManager ( ) : Doctrine\Common\EventManager Get the EventManager used by this Connection.
getMongo ( ) : MongoClient Get the MongoClient instance being wrapped.
getMongoClient ( ) : MongoClient Get the MongoClient instance being wrapped.
getReadPreference ( ) : array Wrapper method for MongoClient::getReadPreference().
getServer ( ) : string | null Get the server string.
getStatus ( ) : string Gets the $status property of the wrapped MongoClient instance.
initialize ( ) Construct the wrapped MongoClient instance if necessary.
isConnected ( ) : boolean Checks whether the connection is initialized and connected.
listDatabases ( ) : array Wrapper method for MongoClient::listDBs().
log ( array $log ) Log something using the configured logger callable (if available).
selectCollection ( string $db, string $collection ) : Doctrine\MongoDB\Collection Wrapper method for MongoClient::selectCollection().
selectDatabase ( string $name ) : Doctrine\MongoDB\Database Wrapper method for MongoClient::selectDatabase().
setMongo ( MongoClient $mongoClient ) Set the MongoClient instance to wrap.
setReadPreference ( string $readPreference, array $tags = null ) : boolean Wrapper method for MongoClient::setReadPreference().

Méthodes protégées

Méthode Description
convertConnectTimeout ( array $options ) : array Converts "timeout" MongoClient constructor option to "connectTimeoutMS" for driver versions 1.4.0+.
convertWriteTimeout ( array $options ) : array Converts "wTimeout" MongoClient constructor option to "wTimeoutMS" for driver versions 1.4.0+.
doSelectDatabase ( string $name ) : Doctrine\MongoDB\Database Return a new Database instance.
retry ( Closure $retry ) : mixed Conditionally retry a closure if it yields an exception.

Method Details

__construct() public méthode

If $server is an existing MongoClient instance, the $options parameter will not be used.
public __construct ( string | MongoClient $server = null, array $options = [], Doctrine\MongoDB\Configuration $config = null, Doctrine\Common\EventManager $evm = null, array $driverOptions = [] )
$server string | MongoClient Server string or MongoClient instance
$options array MongoClient constructor options
$config Doctrine\MongoDB\Configuration Configuration instance
$evm Doctrine\Common\EventManager EventManager instance
$driverOptions array MongoClient constructor options

__get() public méthode

Wrapper method for MongoClient::__get().
See also: http://php.net/manual/en/mongoclient.get.php
public __get ( string $database ) : MongoDB
$database string
Résultat MongoDB

__toString() public méthode

Wrapper method for MongoClient::__toString().
See also: http://php.net/manual/en/mongoclient.tostring.php
public __toString ( ) : string
Résultat string

close() public méthode

Wrapper method for MongoClient::close().
See also: http://php.net/manual/en/mongoclient.close.php
public close ( ) : boolean
Résultat boolean

connect() public méthode

Wrapper method for MongoClient::connect().
See also: http://php.net/manual/en/mongoclient.connect.php
public connect ( ) : boolean
Résultat boolean

convertConnectTimeout() protected méthode

Note: MongoClient actually allows case-insensitive option names, but we'll only process the canonical version here.
protected convertConnectTimeout ( array $options ) : array
$options array
Résultat array

convertWriteTimeout() protected méthode

Note: MongoClient actually allows case-insensitive option names, but we'll only process the canonical version here.
protected convertWriteTimeout ( array $options ) : array
$options array
Résultat array

doSelectDatabase() protected méthode

If a logger callable was defined, a LoggableDatabase will be returned.
See also: Connection::selectDatabase()
protected doSelectDatabase ( string $name ) : Doctrine\MongoDB\Database
$name string
Résultat Doctrine\MongoDB\Database

dropDatabase() public méthode

This method will dispatch preDropDatabase and postDropDatabase events.
See also: http://php.net/manual/en/mongoclient.dropdb.php
public dropDatabase ( string $database ) : array
$database string
Résultat array

getConfiguration() public méthode

Get the Configuration used by this Connection.
public getConfiguration ( ) : Doctrine\MongoDB\Configuration
Résultat Doctrine\MongoDB\Configuration

getEventManager() public méthode

Get the EventManager used by this Connection.
public getEventManager ( ) : Doctrine\Common\EventManager
Résultat Doctrine\Common\EventManager

getMongo() public méthode

Get the MongoClient instance being wrapped.
Deprecation: 1.1 Replaced by getMongoClient(); will be removed for 2.0
public getMongo ( ) : MongoClient
Résultat MongoClient

getMongoClient() public méthode

Get the MongoClient instance being wrapped.
public getMongoClient ( ) : MongoClient
Résultat MongoClient

getReadPreference() public méthode

For driver versions between 1.3.0 and 1.3.3, the return value will be converted for consistency with {@link Connection::setReadPreference()}.
See also: http://php.net/manual/en/mongoclient.getreadpreference.php
public getReadPreference ( ) : array
Résultat array

getServer() public méthode

Get the server string.
public getServer ( ) : string | null
Résultat string | null

getStatus() public méthode

Gets the $status property of the wrapped MongoClient instance.
Deprecation: 1.1 No longer used in driver; Will be removed for 1.2
public getStatus ( ) : string
Résultat string

initialize() public méthode

This method will dispatch preConnect and postConnect events.
public initialize ( )

isConnected() public méthode

Checks whether the connection is initialized and connected.
public isConnected ( ) : boolean
Résultat boolean

listDatabases() public méthode

Wrapper method for MongoClient::listDBs().
See also: http://php.net/manual/en/mongoclient.listdbs.php
public listDatabases ( ) : array
Résultat array

log() public méthode

Log something using the configured logger callable (if available).
public log ( array $log )
$log array

retry() protected méthode

If the closure does not return successfully within the configured number of retries, its first exception will be thrown.
protected retry ( Closure $retry ) : mixed
$retry Closure
Résultat mixed

selectCollection() public méthode

Wrapper method for MongoClient::selectCollection().
See also: http://php.net/manual/en/mongoclient.selectcollection.php
public selectCollection ( string $db, string $collection ) : Doctrine\MongoDB\Collection
$db string
$collection string
Résultat Doctrine\MongoDB\Collection

selectDatabase() public méthode

This method will dispatch preSelectDatabase and postSelectDatabase events.
See also: http://php.net/manual/en/mongoclient.selectdatabase.php
public selectDatabase ( string $name ) : Doctrine\MongoDB\Database
$name string
Résultat Doctrine\MongoDB\Database

setMongo() public méthode

Set the MongoClient instance to wrap.
Deprecation: 1.1 Will be removed for 2.0
public setMongo ( MongoClient $mongoClient )
$mongoClient MongoClient

setReadPreference() public méthode

Wrapper method for MongoClient::setReadPreference().
See also: http://php.net/manual/en/mongoclient.setreadpreference.php
public setReadPreference ( string $readPreference, array $tags = null ) : boolean
$readPreference string
$tags array
Résultat boolean

Property Details

$config protected_oe property

The Configuration for this connection.
protected Configuration,Doctrine\MongoDB $config
Résultat Doctrine\MongoDB\Configuration

$driverOptions protected_oe property

Driver options used to construct the MongoClient instance (optional).
protected array $driverOptions
Résultat array

$eventManager protected_oe property

The EventManager used to dispatch events.
protected EventManager,Doctrine\Common $eventManager
Résultat Doctrine\Common\EventManager

$mongoClient protected_oe property

The PHP MongoClient instance being wrapped.
protected MongoClient $mongoClient
Résultat MongoClient

$options protected_oe property

Options used to construct the MongoClient instance (optional).
protected array $options
Résultat array

$server protected_oe property

Server string used to construct the MongoClient instance (optional).
protected string $server
Résultat string