public getDatabase ( string $name = null ) : |
||
$name | string | database name |
return |
public function getDatabase($name = null)
{
if (!$name) {
$name = $this->getCurrentDatabaseName();
}
if (!isset($this->databasePool[$name])) {
// init db
$database = new Database($this, $name);
if (isset($this->mapping[$name])) {
$database->map($this->mapping[$name]);
}
// configure db
$this->databasePool[$name] = $database;
}
return $this->databasePool[$name];
}
public function setUp() { // connect to mongo $client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null); // select database $database = $client->getDatabase('test'); // select collection $this->collection = $database->getCollection('phpmongo_test_collection'); }