PHP Class Mongo

Author: Johannes Skov Frandsen ([email protected])
Datei anzeigen Open project: alcaeus/mongo-php-adapter Class Usage Examples

Public Methods

Method Description
__construct ( ) Dummy constructor to throw an exception
forceError ( ) : boolean Creates a database error on the database.
getPoolSize ( ) : integer Get pool size for connection pools
getSlave ( ) : boolean Returns the address being used by this for slaveOkay reads
getSlaveOkay ( ) : boolean Get slaveOkay setting for this connection
lastError ( ) : array | null Check if there was an error on the most recent db operation performed
pairConnect ( ) : boolean Connects to paired database server
pairPersistConnect ( string $username = "", string $password = "" ) : boolean Creates a persistent connection with paired database servers
persistConnect ( string $username = "", string $password = "" ) : boolean Creates a persistent connection with a database server
poolDebug ( ) : array Returns information about all connection pools.
prevError ( ) : array Checks for the last error thrown during a database operation
resetError ( ) : array Clears any flagged errors on the connection
setPoolSize ( $size ) : boolean Set the size for future connection pools.
setSlaveOkay ( boolean $ok ) : boolean Change slaveOkay setting for this connection
switchSlave ( ) : string Choose a new secondary for slaveOkay reads

Protected Methods

Method Description
connectUtil ( ) : boolean Connects with a database server
notImplemented ( )

Method Details

__construct() public method

Dummy constructor to throw an exception
public __construct ( )

connectUtil() protected method

Connects with a database server
protected connectUtil ( ) : boolean
return boolean If the connection was successful.

forceError() public method

Creates a database error on the database.
Deprecation: Use MongoDB::forceError() instead.
public forceError ( ) : boolean
return boolean The database response.

getPoolSize() public method

Get pool size for connection pools
Deprecation: This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::getSize() instead.
public getPoolSize ( ) : integer
return integer Returns the current pool size.

getSlave() public method

Returns the address being used by this for slaveOkay reads
public getSlave ( ) : boolean
return boolean The address of the secondary this connection is using for reads. This returns NULL if this is not connected to a replica set or not yet initialized.

getSlaveOkay() public method

Get slaveOkay setting for this connection
public getSlaveOkay ( ) : boolean
return boolean Returns the value of slaveOkay for this instance.

lastError() public method

Check if there was an error on the most recent db operation performed
Deprecation: Use MongoDB::lastError() instead.
public lastError ( ) : array | null
return array | null Returns the error, if there was one, or NULL.

notImplemented() protected method

protected notImplemented ( )

pairConnect() public method

Connects to paired database server
Deprecation: Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method.
public pairConnect ( ) : boolean
return boolean

pairPersistConnect() public method

Creates a persistent connection with paired database servers
Deprecation: Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method.
public pairPersistConnect ( string $username = "", string $password = "" ) : boolean
$username string A username used to identify the connection.
$password string A password used to identify the connection.
return boolean If the connection was successful.

persistConnect() public method

Creates a persistent connection with a database server
Deprecation: Pass array("persist" => $id) to the constructor instead of using this method.
public persistConnect ( string $username = "", string $password = "" ) : boolean
$username string A username used to identify the connection.
$password string A password used to identify the connection.
return boolean If the connection was successful.

poolDebug() public method

Returns information about all connection pools.
Deprecation: This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::info() instead.
public poolDebug ( ) : array
return array

prevError() public method

Checks for the last error thrown during a database operation
Deprecation: Use MongoDB::prevError() instead.
public prevError ( ) : array
return array Returns the error and the number of operations ago it occurred.

resetError() public method

Clears any flagged errors on the connection
Deprecation: Use MongoDB::resetError() instead.
public resetError ( ) : array
return array Returns the database response.

setPoolSize() public method

Set the size for future connection pools.
Deprecation: Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead.
public setPoolSize ( $size ) : boolean
$size

The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.

return boolean Returns the former value of pool size.

setSlaveOkay() public method

Change slaveOkay setting for this connection
public setSlaveOkay ( boolean $ok ) : boolean
$ok boolean
return boolean returns the former value of slaveOkay for this instance.

switchSlave() public method

Choose a new secondary for slaveOkay reads
public switchSlave ( ) : string
return string The address of the secondary this connection is using for reads. This may be the same as the previous address as addresses are randomly chosen. It may return only one address if only one secondary (or only the primary) is available.