本文整理汇总了PHP中AjaxResponse::addData方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::addData方法的具体用法?PHP AjaxResponse::addData怎么用?PHP AjaxResponse::addData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponse
的用法示例。
在下文中一共展示了AjaxResponse::addData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDrop
/**
* Drops trigger.
*/
public function actionDrop()
{
// Get post vars
$triggerName = Yii::app()->request->getPost('trigger');
$response = new AjaxResponse();
try {
$trigger = Trigger::model()->findByPk(array('TRIGGER_SCHEMA' => $this->schema, 'TRIGGER_NAME' => $triggerName));
$sql = $trigger->delete();
$response->addNotification('success', Yii::t('core', 'successDropTrigger', array('{trigger}' => $trigger->TRIGGER_NAME)), null, $sql);
$response->addData('success', true);
} catch (DbException $ex) {
$response->addNotification('error', Yii::t('core', 'errorDropTrigger', array('{trigger}' => $triggerName)), $ex->getText(), $ex->getSql());
$response->addData('success', false);
}
$this->sendJSON($response);
}
示例2: actionDrop
public function actionDrop()
{
// Get post vars
$indexName = Yii::app()->request->getPost('index');
$response = new AjaxResponse();
try {
$index = Index::model()->findByAttributes(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table, 'INDEX_NAME' => $indexName));
$index->throwExceptions = true;
$sql = $index->delete();
$response->addNotification('success', Yii::t('core', 'successDropIndex', array('{index}' => $index->INDEX_NAME)), null, $sql);
$response->addData('success', true);
} catch (DbException $ex) {
$response->addNotification('error', Yii::t('core', 'errorDropIndex', array('{index}' => $indexName)), $ex->getText(), $ex->getSql());
$response->addData('success', false);
}
$this->sendJSON($response);
}
示例3: runImport
public function runImport()
{
$response = new AjaxResponse();
$response->refresh = true;
$response->executeJavaScript('sideBar.loadTables("' . $this->schema . '")');
$this->mimeType = CFileHelper::getMimeType($this->file);
$filesize = filesize($this->file);
// Open file and set position to last position
switch ($this->mimeType) {
// GZip - Files
case 'application/x-gzip':
$handle = gzopen($this->file, 'r');
$content = gzread($handle, $filesize);
gzclose($handle);
break;
// BZip - Files
// BZip - Files
case 'application/x-bzip2':
$handle = bzopen($this->file, 'r');
$content = bzread($handle, $filesize);
bzclose($handle);
break;
// All other files (plain text)
// All other files (plain text)
default:
$content = file_get_contents($this->file);
break;
}
$sqlSplitter = new SqlSplitter($content);
$queries = $sqlSplitter->getQueries();
foreach ($queries as $query) {
try {
$cmd = $this->db->createCommand($query);
# Do NOT prepare the statement, because of double quoting
$cmd->execute();
} catch (CDbException $ex) {
$dbException = new DbException($cmd);
if (!in_array(@$dbException->getNumber(), $this->ignoreErrorNumbers)) {
$dbException = new DbException($cmd);
$response->addNotification('error', Yii::t('core', 'errorExecuteQuery'), $dbException->getText() . ' ' . $dbException->getNumber(), StringUtil::cutText($dbException->getSql(), 100));
$response->addData('error', true);
$response->refresh = true;
@unlink($this->file);
return $response;
}
}
}
$response->addNotification('success', Yii::t('core', 'successImportFile'), Yii::t('core', 'executedQueries') . ":" . count($queries));
// We cannot output json here, see: http://jquery.malsup.com/form/#file-upload
Yii::app()->end($response);
}