/** * Retrieves the database adapter * * @return Zend_Db_Adapter_Abstract */ public function getDb() { if (null === $this->_db) { // Use parent for basic initialization parent::init(); // Has profiler? Attach it to the database adapter if ($this->_db->getProfiler()->getEnabled()) { // Check whether this is a HTTP request; if not, don't use Firebug $this->_bootstrap->bootstrap('Request'); $request = $this->_bootstrap->getResource('Request'); $profiler = $request instanceof Zend_Controller_Request_Http ? new Zend_Db_Profiler_Firebug('Database queries') : new Zend_Db_Profiler(); $profiler->setEnabled(true); $this->_db->setProfiler($profiler); } $this->_setCache(); // Allow application-wide access Glitch_Registry::setDb($this->_db); } return $this->_db; }
public function testInitShouldInitializeDbAdapter() { // require_once 'Zend/Application/Resource/Db.php'; $config = array('adapter' => 'Pdo_Sqlite', 'params' => array('dbname' => ':memory:'), 'isDefaultTableAdapter' => false); $resource = new Zend_Application_Resource_Db($config); $resource->init(); $db = $resource->getDbAdapter(); $this->assertTrue($db instanceof Zend_Db_Adapter_Pdo_Sqlite); }
/** * @group ZF-6620 */ public function testSetOptionFetchMode() { $config = array('bootstrap' => $this->bootstrap, 'adapter' => 'PDO_SQLite', 'params' => array('dbname' => ':memory:', 'options' => array('fetchMode' => 'obj'))); $resource = new Zend_Application_Resource_Db($config); $db = $resource->init(); $this->assertEquals($db->getFetchMode(), Zend_Db::FETCH_OBJ); }
public function init() { $this->_db = parent::init(); $this->_saveInRegistry()->_saveConfigRegistry()->_registerSqliteFunctions(); return $this->_db; }