本文整理汇总了PHP中Engine_Db_Table::setDefaultAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Db_Table::setDefaultAdapter方法的具体用法?PHP Engine_Db_Table::setDefaultAdapter怎么用?PHP Engine_Db_Table::setDefaultAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine_Db_Table
的用法示例。
在下文中一共展示了Engine_Db_Table::setDefaultAdapter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initDb
protected function _initDb()
{
$file = APPLICATION_PATH . '/application/settings/database.php';
$options = (include $file);
$db = Zend_Db::factory($options['adapter'], $options['params']);
Engine_Db_Table::setDefaultAdapter($db);
Engine_Db_Table::setTablePrefix($options['tablePrefix']);
// Non-production
if (APPLICATION_ENV !== 'production') {
$db->setProfiler(array('class' => 'Zend_Db_Profiler_Firebug', 'enabled' => true));
}
// set DB to UTC timezone for this session
switch ($options['adapter']) {
case 'mysqli':
case 'mysql':
case 'pdo_mysql':
$db->query("SET time_zone = '+0:00'");
break;
case 'postgresql':
$db->query("SET time_zone = '+0:00'");
break;
default:
// do nothing
}
// attempt to disable strict mode
try {
$db->query("SET SQL_MODE = ''");
} catch (Exception $e) {
}
return $db;
}
示例2: _initDb
protected function _initDb()
{
if (file_exists(APPLICATION_PATH . '/application/settings/database.php')) {
$config = (include APPLICATION_PATH . '/application/settings/database.php');
if (!empty($config['adapter'])) {
try {
$db = Zend_Db::factory($config['adapter'], $config['params']);
$db->getServerVersion();
// Forces the connection open
} catch (Exception $e) {
$this->getContainer()->log->log($e, Zend_Log::WARN);
return;
}
Zend_Registry::set('Zend_Db', $db);
// set DB to UTC timezone for this session
switch ($config['adapter']) {
case 'mysqli':
case 'mysql':
case 'pdo_mysql':
$db->query("SET time_zone = '+0:00'");
break;
case 'postgresql':
$db->query("SET time_zone = '+0:00'");
break;
default:
// do nothing
}
// attempt to disable strict mode
try {
$db->query("SET SQL_MODE = ''");
} catch (Exception $e) {
}
Engine_Db_Table::setDefaultAdapter($db);
return $db;
}
}
}