PHP Class Phalcon\Db\Adapter\MongoDB\Database

显示文件 Open project: phalcon/incubator

Public Methods

Method Description
__construct ( MongoDB\Driver\Manager $manager, string $databaseName, array $options = [] ) Constructs new Database instance.
__debugInfo ( ) : array Return internal properties for debugging purposes.
__get ( string $collectionName ) : Collection Select a collection within this database.
__toString ( ) : string Return the database name.
command ( array | object $command, array $options = [] ) : MongoDB\Driver\Cursor Execute a command on this database.
createCollection ( string $collectionName, array $options = [] ) : array | object Create a new collection explicitly.
drop ( array $options = [] ) : array | object Drop this database.
dropCollection ( string $collectionName, array $options = [] ) : array | object Drop a collection within this database.
getDatabaseName ( ) : string Returns the database name.
listCollections ( array $options = [] ) : Phalcon\Db\Adapter\MongoDB\Model\CollectionInfoIterator Returns information for all collections in this database.
selectCollection ( string $collectionName, array $options = [] ) : Collection Select a collection within this database.
withOptions ( array $options = [] ) : Database Get a clone of this database with different options.

Method Details

__construct() public method

This class provides methods for database-specific operations and serves as a gateway for accessing collections. Supported options: * readConcern (MongoDB\Driver\ReadConcern): The default read concern to use for database operations and selected collections. Defaults to the Manager's read concern. * readPreference (MongoDB\Driver\ReadPreference): The default read preference to use for database operations and selected collections. Defaults to the Manager's read preference. * typeMap (array): Default type map for cursors and BSON documents. * writeConcern (MongoDB\Driver\WriteConcern): The default write concern to use for database operations and selected collections. Defaults to the Manager's write concern.
public __construct ( MongoDB\Driver\Manager $manager, string $databaseName, array $options = [] )
$manager MongoDB\Driver\Manager Manager instance from the driver
$databaseName string Database name
$options array Database 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: collections whose names contain special characters (e.g. ".") may be selected with complex syntax (e.g. $database->{"system.profile"}) or {@link selectCollection()}.
See also: http://php.net/oop5.overloading#object.get
See also: http://php.net/types.string#language.types.string.parsing.complex
public __get ( string $collectionName ) : Collection
$collectionName string Name of the collection to select
return Collection

__toString() public method

Return the database name.
public __toString ( ) : string
return string

command() public method

Execute a command on this database.
See also: DatabaseCommand::__construct() for supported options
public command ( array | object $command, array $options = [] ) : MongoDB\Driver\Cursor
$command array | object Command document
$options array Options for command execution
return MongoDB\Driver\Cursor

createCollection() public method

Create a new collection explicitly.
See also: CreateCollection::__construct() for supported options
public createCollection ( string $collectionName, array $options = [] ) : array | object
$collectionName string
$options array
return array | object Command result document

drop() public method

Drop this database.
See also: DropDatabase::__construct() for supported options
public drop ( array $options = [] ) : array | object
$options array Additional options
return array | object Command result document

dropCollection() public method

Drop a collection within this database.
See also: DropCollection::__construct() for supported options
public dropCollection ( string $collectionName, array $options = [] ) : array | object
$collectionName string Collection name
$options array Additional options
return array | object Command result document

getDatabaseName() public method

Returns the database name.
public getDatabaseName ( ) : string
return string

listCollections() public method

Returns information for all collections in this database.
See also: ListCollections::__construct() for supported options
public listCollections ( array $options = [] ) : Phalcon\Db\Adapter\MongoDB\Model\CollectionInfoIterator
$options array
return Phalcon\Db\Adapter\MongoDB\Model\CollectionInfoIterator

selectCollection() public method

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

withOptions() public method

Get a clone of this database with different options.
See also: Database::__construct() for supported options
public withOptions ( array $options = [] ) : Database
$options array Database constructor options
return Database