Commit daed771c authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #10 from jmikola/phplib-89

PHPLIB-89: String getters for Database and Collection classes
parents 76d62e2e c9ebbbdf
...@@ -69,6 +69,16 @@ class Collection ...@@ -69,6 +69,16 @@ class Collection
list($this->dbname, $this->collname) = explode(".", $namespace, 2); 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 * Runs an aggregation framework pipeline
* *
...@@ -629,7 +639,7 @@ class Collection ...@@ -629,7 +639,7 @@ class Collection
} }
/** /**
* Returns the CollectionName this object operates on * Return the collection name.
* *
* @return string * @return string
*/ */
...@@ -677,7 +687,7 @@ class Collection ...@@ -677,7 +687,7 @@ class Collection
} }
/** /**
* Returns the DatabaseName this object operates on * Return the database name.
* *
* @return string * @return string
*/ */
...@@ -931,6 +941,17 @@ class Collection ...@@ -931,6 +941,17 @@ class Collection
); );
} }
/**
* 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. * Retrieves all Write options with their default values.
* *
......
...@@ -41,6 +41,16 @@ class Database ...@@ -41,6 +41,16 @@ class Database
$this->readPreference = $readPreference; $this->readPreference = $readPreference;
} }
/**
* Return the database name.
*
* @param string
*/
public function __toString()
{
return $this->databaseName;
}
/** /**
* Create a new collection explicitly. * Create a new collection explicitly.
* *
...@@ -89,6 +99,16 @@ class Database ...@@ -89,6 +99,16 @@ class Database
return $this->manager->executeCommand($this->databaseName, $command, $readPreference); 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. * Returns information for all collections in this database.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment