本文整理匯總了PHP中CDbConnection::open方法的典型用法代碼示例。如果您正苦於以下問題:PHP CDbConnection::open方法的具體用法?PHP CDbConnection::open怎麽用?PHP CDbConnection::open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CDbConnection
的用法示例。
在下文中一共展示了CDbConnection::open方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: open
/**
* @inheritdoc
*/
protected function open()
{
parent::open();
if ($this->hasEventHandler('onAfterOpen')) {
$this->onAfterOpen(new \CEvent($this));
}
}
示例2: open
protected function open()
{
try {
parent::open();
} catch (Exception $e) {
$error = $e->getMessage();
$msg = 'Failed to connect to the ' . $this->type . ' database.<br/>';
$msg .= 'The error message is: ' . $error . '<br/>';
if (!Yii::app()->controller instanceof InstallController) {
$msg .= '<br/>Please run the ' . CHtml::link('control panel installer', Yii::app()->request->getBaseUrl(true) . '/install.php') . ' to fix this issue.<br/>';
}
throw new RawHttpException(500, $msg);
}
}
示例3: open
/**
* Opens DB connection if it is currently not
* @throws CException if connection fails
*/
protected function open()
{
try {
parent::open();
} catch (Exception $exception) {
// email notif ke Developer/Sysadmin buat restart service
$email = new EmailSender();
$email->setSubject('Critical Error - Database not active');
$email->setBody($exception->getMessage() . '<br />' . CHtml::link('Restart Database Service', 'https://bmustudio.com:8083/restart/service/?srv=mysql'));
$email->setTo([Yii::app()->params['emails']['sysadmin'] => Yii::app()->params['emails']['sysadmin']]);
$email->setCC(Yii::app()->params['emails']['developerList']);
$email->send();
throw new CHttpException(500, "Maaf database sedang kami matikan sementara, coba akses beberapa saat lagi.");
}
}
示例4: open
protected function open()
{
if ($this->connectionString) {
return parent::open();
}
shuffle($this->dbaConnections);
$dl = count($this->dbaConnections);
for ($i = 0; $i < $dl; $i++) {
try {
$this->connectionString = $this->dbaConnections[$i];
return parent::open();
} catch (Exception $e) {
Yii::app()->logging->logDebug('dba連接失敗.', array('connectionString' => $this->connectionString, 'Exception' => $e->getMessage()));
continue;
}
}
throw new CDbException('完了, 數據庫連接所有都失敗了.');
}