protected function _checkDbTable() { if (null !== $this->_dbRessource) { $tablesToCheck = array(); $tablesNotFound = array(); $tablesToCheck[] = 'auth_belong'; $tablesToCheck[] = 'auth_group'; $tablesToCheck[] = 'auth_group_permission'; $tablesToCheck[] = 'auth_permission'; $tablesToCheck[] = 'auth_user'; $tablesToCheck[] = 'auth_user_permission'; $tablesToCheck[] = 'centurion_content_type'; $tablesToCheck[] = 'centurion_navigation'; $tablesToCheck[] = 'centurion_site'; $tablesToCheck[] = 'cms_flatpage'; $tablesToCheck[] = 'cms_flatpage_template'; $tablesToCheck[] = 'media_duplicate'; $tablesToCheck[] = 'media_file'; $tablesToCheck[] = 'media_image'; $tablesToCheck[] = 'media_multiupload_ticket'; $tablesToCheck[] = 'media_video'; $tablesToCheck[] = 'translation_language'; $tablesToCheck[] = 'translation_tag'; $tablesToCheck[] = 'translation_tag_uid'; $tablesToCheck[] = 'translation_translation'; $tablesToCheck[] = 'translation_uid'; $tablesToCheck[] = 'user_profile'; foreach ($tablesToCheck as $tableName) { try { $this->_dbRessource->getDbAdapter()->describeTable($tableName); } catch (Exception $e) { if ($e->getCode() == '42') { $tablesNotFound[] = $tableName; } else { throw $e; } } } if (count($tablesNotFound) > 0) { if (count($tablesNotFound) == count($tablesToCheck)) { //TODO: zf db install $this->_checklist[] = array('code' => -1, 'canBeBetter' => true, 'isNotSecure' => false, 'text' => 'All table are missing.', 'alt' => 'Have you forget a "zf db install" ?'); } else { $this->_checklist[] = array('code' => 0, 'canBeBetter' => true, 'isNotSecure' => false, 'text' => 'Some table are missing', 'alt' => 'Some table are missing: <br /> - ' . implode('<br />- ', $tablesNotFound)); } } } else { $this->_checklist[] = array('code' => -1, 'canBeBetter' => true, 'isNotSecure' => true, 'text' => 'Can\'t check table; no connection to bdd', 'alt' => ''); } }
/** * 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 getDbAdapter() { if (self::$_cachedAdapter instanceof Zend_Db_Adapter_Abstract) { $adapter = self::$_cachedAdapter; } else { $adapter = parent::getDbAdapter(); } return $adapter; }
public function init() { $this->_db = parent::init(); $this->_saveInRegistry()->_saveConfigRegistry()->_registerSqliteFunctions(); return $this->_db; }