PHP Class MongoDB

Afficher le fichier Open project: alcaeus/mongo-php-adapter Class Usage Examples

Protected Properties

Свойство Type Description
$connection MongoClient
$db MongoDB\Database
$name string

Méthodes publiques

Méthode Description
__construct ( MongoClient $conn, string $name ) Creates a new database
__get ( string $name ) : MongoCollection Gets a collection
__set ( string $name, mixed $value )
__sleep ( ) : array
__toString ( ) : string The name of this database
authenticate ( string $username, string $password ) : array Log in to this database
command ( array $data, array $options = [], &$hash = null ) : array Execute a database command
createCollection ( string $name, array $options ) : MongoCollection Creates a collection
createDBRef ( string $collection, mixed $document_or_id ) : array Creates a database reference
drop ( ) : array Drops this database
dropCollection ( MongoCollection | string $coll ) : array Drops a collection
execute ( MongoCode | string $code, array $args = [] ) : array Runs JavaScript code on the database server.
forceError ( ) : boolean Creates a database error
getCollectionInfo ( array $options = [] ) : array Returns information about collections in this database
getCollectionNames ( array $options = [] ) : array Get all collections from this database
getConnection ( ) : MongoClient
getDBRef ( array $ref ) : array Fetches the document pointed to by a database reference
getDb ( ) : MongoDB\Database
getGridFS ( string $prefix = "fs" ) : MongoGridFS Fetches toolkit for dealing with files stored in this database
getProfilingLevel ( ) : integer Gets this database's profiling level
lastError ( ) : array Check if there was an error on the most recent db operation performed
listCollections ( array $options = [] ) : MongoCollection[] Get a list of collections in this database
prevError ( ) : array Checks for the last error thrown during a database operation
repair ( boolean $preserve_cloned_files = FALSE, boolean $backup_original_files = FALSE ) : array Repairs and compacts this database
resetError ( ) : array Clears any flagged errors on the database
selectCollection ( string $name ) : MongoCollection Gets a collection
setProfilingLevel ( integer $level ) : integer Sets this database's profiling level
setReadPreference ( $readPreference, $tags = null )
setWriteConcern ( $wstring, $wtimeout )

Méthodes protégées

Méthode Description
notImplemented ( )

Private Methods

Méthode Description
checkDatabaseName ( $name )
createDatabaseObject ( ) : MongoDB\Database
getSystemCollectionFilterClosure ( boolean $includeSystemCollections = false ) : Closure

Method Details

__construct() public méthode

This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through {@see \Mongo::__get()} or {@see \Mongo::selectDB()}.
public __construct ( MongoClient $conn, string $name )
$conn MongoClient Database connection.
$name string Database name.

__get() public méthode

Gets a collection
public __get ( string $name ) : MongoCollection
$name string The name of the collection.
Résultat MongoCollection

__set() public méthode

public __set ( string $name, mixed $value )
$name string
$value mixed

__sleep() public méthode

public __sleep ( ) : array
Résultat array

__toString() public méthode

The name of this database
public __toString ( ) : string
Résultat string Returns this database's name.

authenticate() public méthode

Log in to this database
Deprecation: This method is not implemented, supply authentication credentials through the connection string instead.
public authenticate ( string $username, string $password ) : array
$username string The username.
$password string The password (in plaintext).
Résultat array Returns database response. If the login was successful, it will return 1.

command() public méthode

Execute a database command
public command ( array $data, array $options = [], &$hash = null ) : array
$data array The query to send.
$options array
Résultat array Returns database response.

createCollection() public méthode

Creates a collection
public createCollection ( string $name, array $options ) : MongoCollection
$name string The name of the collection.
$options array
Résultat MongoCollection Returns a collection object representing the new collection.

createDBRef() public méthode

Creates a database reference
public createDBRef ( string $collection, mixed $document_or_id ) : array
$collection string The collection to which the database reference will point.
$document_or_id mixed
Résultat array Returns a database reference array.

drop() public méthode

Drops this database
public drop ( ) : array
Résultat array Returns the database response.

dropCollection() public méthode

Drops a collection
Deprecation: Use MongoCollection::drop() instead.
public dropCollection ( MongoCollection | string $coll ) : array
$coll MongoCollection | string MongoCollection or name of collection to drop.
Résultat array Returns the database response.

execute() public méthode

Runs JavaScript code on the database server.
public execute ( MongoCode | string $code, array $args = [] ) : array
$code MongoCode | string Code to execute.
$args array [optional] Arguments to be passed to code.
Résultat array Returns the result of the evaluation.

forceError() public méthode

Creates a database error
public forceError ( ) : boolean
Résultat boolean Returns the database response.

getCollectionInfo() public méthode

Returns information about collections in this database
public getCollectionInfo ( array $options = [] ) : array
$options array An array of options for listing the collections.
Résultat array

getCollectionNames() public méthode

Get all collections from this database
public getCollectionNames ( array $options = [] ) : array
$options array An array of options for listing the collections.
Résultat array Returns the names of the all the collections in the database as an array

getConnection() public méthode

public getConnection ( ) : MongoClient
Résultat MongoClient

getDBRef() public méthode

Fetches the document pointed to by a database reference
public getDBRef ( array $ref ) : array
$ref array A database reference.
Résultat array Returns the document pointed to by the reference.

getDb() public méthode

public getDb ( ) : MongoDB\Database
Résultat MongoDB\Database

getGridFS() public méthode

Fetches toolkit for dealing with files stored in this database
public getGridFS ( string $prefix = "fs" ) : MongoGridFS
$prefix string The prefix for the files and chunks collections.
Résultat MongoGridFS Returns a new gridfs object for this database.

getProfilingLevel() public méthode

Gets this database's profiling level
public getProfilingLevel ( ) : integer
Résultat integer Returns the profiling level.

lastError() public méthode

Check if there was an error on the most recent db operation performed
public lastError ( ) : array
Résultat array Returns the error, if there was one.

listCollections() public méthode

Get a list of collections in this database
public listCollections ( array $options = [] ) : MongoCollection[]
$options array
Résultat MongoCollection[] Returns a list of MongoCollections.

notImplemented() protected méthode

protected notImplemented ( )

prevError() public méthode

Checks for the last error thrown during a database operation
public prevError ( ) : array
Résultat array Returns the error and the number of operations ago it occurred.

repair() public méthode

Repairs and compacts this database
public repair ( boolean $preserve_cloned_files = FALSE, boolean $backup_original_files = FALSE ) : array
$preserve_cloned_files boolean [optional]

If cloned files should be kept if the repair fails.

$backup_original_files boolean [optional]

If original files should be backed up.

Résultat array

Returns db response.

resetError() public méthode

Clears any flagged errors on the database
public resetError ( ) : array
Résultat array Returns the database response.

selectCollection() public méthode

Gets a collection
public selectCollection ( string $name ) : MongoCollection
$name string The collection name.
Résultat MongoCollection Returns a new collection object.

setProfilingLevel() public méthode

Sets this database's profiling level
public setProfilingLevel ( integer $level ) : integer
$level integer Profiling level.
Résultat integer Returns the previous profiling level.

setReadPreference() public méthode

public setReadPreference ( $readPreference, $tags = null )

setWriteConcern() public méthode

public setWriteConcern ( $wstring, $wtimeout )

Property Details

$connection protected_oe property

protected MongoClient $connection
Résultat MongoClient

$db protected_oe property

protected Database,MongoDB $db
Résultat MongoDB\Database

$name protected_oe property

protected string $name
Résultat string