MongoDB
class MongoDB (View source)
Instances of this class are used to interact with a database.
Constants
PROFILING_OFF |
Profiling is off. |
PROFILING_SLOW |
Profiling is on for slow operations (>100 ms). |
PROFILING_ON |
Profiling is on for all operations. |
Properties
int | $w | ||
int | $wtimeout |
Methods
(PECL mongo >= 0.9.0)
Creates a new database
This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through {Mongo::__get()} or {Mongo::selectDB()}.
The name of this database
(PECL mongo >= 1.0.2)
Gets a collection
(PECL mongo >= 1.3.0)
(PECL mongo >= 0.9.0)
Fetches toolkit for dealing with files stored in this database
(PECL mongo >= 0.9.0)
Gets this database's profiling level
(PECL mongo >= 1.1.0)
Get slaveOkay setting for this database
(PECL mongo >= 0.9.0)
Sets this database's profiling level
(PECL mongo >= 0.9.0)
Drops this database
Repairs and compacts this database
(PECL mongo >= 0.9.0)
Gets a collection
(PECL mongo >= 1.1.0)
Change slaveOkay setting for this database
Creates a collection
(PECL mongo >= 0.9.0)
Get a list of collections in this database
(PECL mongo >= 0.9.0)
Creates a database reference
(PECL mongo >= 0.9.0)
Fetches the document pointed to by a database reference
(PECL mongo >= 1.5.0)
Get the write concern for this database
Execute a database command
(PECL mongo >= 0.9.5)
Check if there was an error on the most recent db operation performed
(PECL mongo >= 0.9.5)
Checks for the last error thrown during a database operation
(PECL mongo >= 0.9.5)
Clears any flagged errors on the database
(PECL mongo >= 0.9.5)
Creates a database error
(PECL mongo >= 1.0.1)
Log in to this database
(PECL mongo >= 1.3.0)
Get the read preference for this database
(PECL mongo >= 1.3.0)
Set the read preference for this database
(PECL mongo >= 1.5.0)
Details
__construct(MongoClient $conn, string $name)
(PECL mongo >= 0.9.0)
Creates a new database
This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through {Mongo::__get()} or {Mongo::selectDB()}.
string
__toString()
The name of this database
MongoCollection
__get(string $name)
(PECL mongo >= 1.0.2)
Gets a collection
array
getCollectionNames(bool $includeSystemCollections = false)
(PECL mongo >= 1.3.0)
MongoGridFS
getGridFS(string $prefix = "fs")
(PECL mongo >= 0.9.0)
Fetches toolkit for dealing with files stored in this database
int
getProfilingLevel()
(PECL mongo >= 0.9.0)
Gets this database's profiling level
bool
getSlaveOkay()
(PECL mongo >= 1.1.0)
Get slaveOkay setting for this database
int
setProfilingLevel(int $level)
(PECL mongo >= 0.9.0)
Sets this database's profiling level
array
drop()
(PECL mongo >= 0.9.0)
Drops this database
array
repair(bool $preserve_cloned_files = false, bool $backup_original_files = false)
Repairs and compacts this database
MongoCollection
selectCollection(string $name)
(PECL mongo >= 0.9.0)
Gets a collection
bool
setSlaveOkay(bool $ok = true)
(PECL mongo >= 1.1.0)
Change slaveOkay setting for this database
MongoCollection
createCollection(string $name, array $options)
Creates a collection
array
dropCollection(MongoCollection|string $coll)
(PECL mongo >= 0.9.0)
Drops a collection
array
listCollections(bool $includeSystemCollections = false)
(PECL mongo >= 0.9.0)
Get a list of collections in this database
array
createDBRef(string $collection, mixed $document_or_id)
(PECL mongo >= 0.9.0)
Creates a database reference
array
getDBRef(array $ref)
(PECL mongo >= 0.9.0)
Fetches the document pointed to by a database reference
array
getWriteConcern()
(PECL mongo >= 1.5.0)
Get the write concern for this database
array
execute(MongoCode|string $code, array $args = [])
(PECL mongo >= 0.9.3)
Runs JavaScript code on the database server.
array
command(array $data, array $options)
Execute a database command
array
lastError()
(PECL mongo >= 0.9.5)
Check if there was an error on the most recent db operation performed
array
prevError()
(PECL mongo >= 0.9.5)
Checks for the last error thrown during a database operation
array
resetError()
(PECL mongo >= 0.9.5)
Clears any flagged errors on the database
bool
forceError()
(PECL mongo >= 0.9.5)
Creates a database error
array
authenticate(string $username, string $password)
(PECL mongo >= 1.0.1)
Log in to this database
array
getReadPreference()
(PECL mongo >= 1.3.0)
Get the read preference for this database
bool
setReadPreference(string $read_preference, array $tags)
(PECL mongo >= 1.3.0)
Set the read preference for this database
bool
setWriteConcern(mixed $w, int $wtimeout)
(PECL mongo >= 1.5.0)