本文整理汇总了PHP中AjaxResponse::executeJavaScript方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::executeJavaScript方法的具体用法?PHP AjaxResponse::executeJavaScript怎么用?PHP AjaxResponse::executeJavaScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponse
的用法示例。
在下文中一共展示了AjaxResponse::executeJavaScript方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDrop
/**
* Drops tables
*/
public function actionDrop()
{
$response = new AjaxResponse();
if (!Yii::app()->getRequest()->getParam('redirectOnSuccess')) {
$response->refresh = true;
}
$response->executeJavaScript('sideBar.loadTables(schema);');
$tables = (array) $_POST['tables'];
$droppedTables = $droppedSqls = array();
foreach ($tables as $table) {
$tableObj = Table::model()->findByPk(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $table));
$tableObj->throwExceptions = true;
try {
$sql = $tableObj->delete();
$droppedTables[] = $table;
$droppedSqls[] = $sql;
} catch (DbException $ex) {
$response->addNotification('error', Yii::t('core', 'errorDropTable', array('{table}' => $table)), $ex->getText(), $ex->getSql());
}
}
$count = count($droppedTables);
if ($count > 0) {
$response->addNotification('success', Yii::t('core', 'successDropTable', array($count, '{table}' => $droppedTables[0], '{tableCount}' => $count)), $count > 1 ? implode(', ', $droppedTables) : null, implode("\n", $droppedSqls));
if (Yii::app()->getRequest()->getParam('redirectOnSuccess')) {
$response->redirectUrl = '#tables';
}
}
$this->sendJSON($response);
}
示例2: actionDrop
/**
* Drops views.
*/
public function actionDrop()
{
$response = new AjaxResponse();
$response->refresh = true;
$response->executeJavaScript('sideBar.loadViews(schema);');
$views = (array) $_POST['views'];
$droppedViews = $droppedSqls = array();
foreach ($views as $view) {
$viewObj = View::model()->findByPk(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $view));
try {
$sql = $viewObj->delete();
$droppedViews[] = $view;
$droppedSqls[] = $sql;
} catch (DbException $ex) {
$response->addNotification('error', Yii::t('core', 'errorDropView', array('{view}' => $view)), $ex->getText(), $ex->getSql());
}
}
$count = count($droppedViews);
if ($count > 0) {
$response->addNotification('success', Yii::t('core', 'successDropView', array($count, '{view}' => $droppedViews[0], '{viewCount}' => $count)), $count > 1 ? implode(', ', $droppedViews) : null, implode("\n", $droppedSqls));
}
$this->sendJSON($response);
}
示例3: actionDrop
/**
* Drop a schema.
*/
public function actionDrop()
{
$response = new AjaxResponse();
$response->refresh = true;
$response->executeJavaScript('sideBar.loadSchemata()');
$schemata = (array) $_POST['schemata'];
$droppedSchemata = $droppedSqls = array();
Schema::$db = Yii::app()->getDb();
foreach ($schemata as $schema) {
$schemaObj = Schema::model()->findByPk($schema);
$schemaObj->throwExceptions = true;
try {
$sql = $schemaObj->delete();
$droppedSchemata[] = $schema;
$droppedSqls[] = $sql;
} catch (DbException $ex) {
$response->addNotification('error', Yii::t('core', 'errorDropSchema', array('{schema}' => $schema)), $ex->getText(), $ex->getSql());
}
}
$count = count($droppedSchemata);
if ($count > 0) {
$response->addNotification('success', Yii::t('core', 'successDropSchema', array($count, '{schema}' => $droppedSchemata[0], '{schemaCount}' => $count)), $count > 1 ? implode(', ', $droppedSchemata) : null, implode("\n", $droppedSqls));
}
$this->sendJSON($response);
}
示例4: 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);
}