示例#1
0
 /**
  * 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;
 }
示例#2
0
文件: DbTest.php 项目: netvlies/zf
 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);
 }
示例#3
0
文件: DbTest.php 项目: jsnshrmn/Suma
 /**
  * @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);
 }
示例#4
0
 public function init()
 {
     $this->_db = parent::init();
     $this->_saveInRegistry()->_saveConfigRegistry()->_registerSqliteFunctions();
     return $this->_db;
 }