diff --git a/src/Collection.php b/src/Collection.php index 0c3d1f036..a3cddee23 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -69,6 +69,16 @@ public function __construct(Manager $manager, $namespace, WriteConcern $writeCon list($this->dbname, $this->collname) = explode(".", $namespace, 2); } + /** + * Return the collection namespace. + * + * @param string + */ + public function __toString() + { + return $this->ns; + } + /** * Runs an aggregation framework pipeline * @@ -629,7 +639,7 @@ public function getBulkOptions() } /** - * Returns the CollectionName this object operates on + * Return the collection name. * * @return string */ @@ -677,7 +687,7 @@ public function getCountOptions() } /** - * Returns the DatabaseName this object operates on + * Return the database name. * * @return string */ @@ -931,6 +941,17 @@ public function getFindOptions() ); } + /** + * Return the collection namespace. + * + * @see http://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace + * @return string + */ + public function getNamespace() + { + return $this->ns; + } + /** * Retrieves all Write options with their default values. * diff --git a/src/Database.php b/src/Database.php index b50a9ea48..8ca8d11c4 100644 --- a/src/Database.php +++ b/src/Database.php @@ -41,6 +41,16 @@ public function __construct(Manager $manager, $databaseName, WriteConcern $write $this->readPreference = $readPreference; } + /** + * Return the database name. + * + * @param string + */ + public function __toString() + { + return $this->databaseName; + } + /** * Create a new collection explicitly. * @@ -89,6 +99,16 @@ public function dropCollection($collectionName) return $this->manager->executeCommand($this->databaseName, $command, $readPreference); } + /** + * Returns the database name. + * + * @return string + */ + public function getDatabaseName() + { + return $this->databaseName; + } + /** * Returns information for all collections in this database. *