PHP Class Phalcon\Db\Adapter\MongoDB\Client

Mostra file Open project: phalcon/incubator Class Usage Examples

Public Methods

Method Description
__construct ( string $uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = [] ) Constructs a new Client instance.
__debugInfo ( ) : array Return internal properties for debugging purposes.
__get ( string $databaseName ) : Database Select a database.
__toString ( ) : string Return the connection string (i.e. URI).
dropDatabase ( string $databaseName, array $options = [] ) : array | object Drop a database.
listDatabases ( array $options = [] ) : Phalcon\Db\Adapter\MongoDB\Model\DatabaseInfoIterator List databases.
selectCollection ( string $databaseName, string $collectionName, array $options = [] ) : Collection Select a collection.
selectDatabase ( string $databaseName, array $options = [] ) : Database Select a database.

Method Details

__construct() public method

This is the preferred class for connecting to a MongoDB server or cluster of servers. It serves as a gateway for accessing individual databases and collections. Supported driver-specific options: * typeMap (array): Default type map for cursors and BSON documents. Other options are documented in MongoDB\Driver\Manager::__construct().
See also: http://docs.mongodb.org/manual/reference/connection-string/
See also: http://php.net/manual/en/mongodb-driver-manager.construct.php
See also: http://php.net/manual/en/mongodb.persistence.php#mongodb.persistence.typemaps
public __construct ( string $uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = [] )
$uri string MongoDB connection string
$uriOptions array Additional connection string options
$driverOptions array Driver-specific options

__debugInfo() public method

Return internal properties for debugging purposes.
See also: http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
public __debugInfo ( ) : array
return array

__get() public method

Note: databases whose names contain special characters (e.g. "-") may be selected with complex syntax (e.g. $client->{"that-database"}) or {@link selectDatabase()}.
See also: http://php.net/oop5.overloading#object.get
See also: http://php.net/types.string#language.types.string.parsing.complex
public __get ( string $databaseName ) : Database
$databaseName string Name of the database to select
return Database

__toString() public method

Return the connection string (i.e. URI).
public __toString ( ) : string
return string

dropDatabase() public method

Drop a database.
See also: DropDatabase::__construct() for supported options
public dropDatabase ( string $databaseName, array $options = [] ) : array | object
$databaseName string Database name
$options array Additional options
return array | object Command result document

listDatabases() public method

List databases.
See also: ListDatabases::__construct() for supported options
public listDatabases ( array $options = [] ) : Phalcon\Db\Adapter\MongoDB\Model\DatabaseInfoIterator
$options array
return Phalcon\Db\Adapter\MongoDB\Model\DatabaseInfoIterator

selectCollection() public method

Select a collection.
See also: Collection::__construct() for supported options
public selectCollection ( string $databaseName, string $collectionName, array $options = [] ) : Collection
$databaseName string Name of the database containing the collection
$collectionName string Name of the collection to select
$options array Collection constructor options
return Collection

selectDatabase() public method

Select a database.
See also: Database::__construct() for supported options
public selectDatabase ( string $databaseName, array $options = [] ) : Database
$databaseName string Name of the database to select
$options array Database constructor options
return Database