/** * Returns the MongoDB instance for a class. * * @param string $className The class name. * @return Doctrine\ODM\MongoDB\MongoDB */ public function getDocumentDB($className) { $db = $this->_metadataFactory->getMetadataFor($className)->getDB(); $db = $db ? $db : $this->_config->getDefaultDB(); $db = $db ? $db : 'doctrine'; $db = sprintf('%s%s', $this->_config->getEnvironmentPrefix(), $db); if ($db && !isset($this->_documentDBs[$db])) { $database = $this->_mongo->selectDB($db); $this->_documentDBs[$db] = new MongoDB($database); } if (!isset($this->_documentDBs[$db])) { throw MongoDBException::documentNotMappedToDB($className); } return $this->_documentDBs[$db]; }
/** * Returns the MongoDB instance for a class. * * @param string $className The class name. * @return Doctrine\ODM\MongoDB\MongoDB */ public function getDocumentDB($className) { $db = $this->_metadataFactory->getMetadataFor($className)->getDB(); if ($db && !isset($this->_documentDBs[$db])) { $database = $this->_mongo->selectDB($db); $this->_documentDBs[$db] = new MongoDB($database); } if (!isset($this->_documentDBs[$db])) { throw MongoDBException::documentNotMappedToDB($className); } return $this->_documentDBs[$db]; }