本文整理匯總了PHP中Trigger::getCreateTrigger方法的典型用法代碼示例。如果您正苦於以下問題:PHP Trigger::getCreateTrigger方法的具體用法?PHP Trigger::getCreateTrigger怎麽用?PHP Trigger::getCreateTrigger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Trigger
的用法示例。
在下文中一共展示了Trigger::getCreateTrigger方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
/**
* Updates a trigger.
*/
public function actionUpdate()
{
$trigger = Trigger::model()->findByPk(array('TRIGGER_SCHEMA' => $this->schema, 'TRIGGER_NAME' => $this->trigger));
if (is_null($trigger)) {
$trigger = new Trigger();
}
if (isset($_POST['query'])) {
$query = $_POST['query'];
try {
// Split queries
$splitter = new SqlSplitter($query);
$splitter->delimiter = self::$delimiter;
$queries = $splitter->getQueries();
foreach ($queries as $query2) {
$cmd = $this->db->createCommand($query2);
$cmd->prepare();
$cmd->execute();
}
$response = new AjaxResponse();
$response->addNotification('success', Yii::t('core', 'successAlterTrigger'), null, $query);
$response->refresh = true;
$this->sendJSON($response);
} catch (CDbException $ex) {
$errorInfo = $cmd->getPdoStatement()->errorInfo();
$trigger->addError(null, Yii::t('core', 'sqlErrorOccured', array('{errno}' => $errorInfo[1], '{errmsg}' => $errorInfo[2])));
}
} else {
$query = 'DROP TRIGGER ' . $this->db->quoteTableName($trigger->TRIGGER_NAME) . self::$delimiter . "\n" . $trigger->getCreateTrigger();
}
CHtml::generateRandomIdPrefix();
$this->render('form', array('trigger' => $trigger, 'query' => $query));
}