本文整理汇总了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('完了, 数据库连接所有都失败了.');
}