当前位置: 首页>>代码示例>>PHP>>正文


PHP AjaxResponse::addNotification方法代码示例

本文整理汇总了PHP中AjaxResponse::addNotification方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::addNotification方法的具体用法?PHP AjaxResponse::addNotification怎么用?PHP AjaxResponse::addNotification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AjaxResponse的用法示例。


在下文中一共展示了AjaxResponse::addNotification方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionKillProcess

 /**
  * Kills a process on the server.
  */
 public function actionKillProcess()
 {
     $ids = CJSON::decode(Yii::app()->getRequest()->getParam('ids'));
     $response = new AjaxResponse();
     $response->refresh = true;
     foreach ($ids as $id) {
         $sql = 'KILL ' . $id;
         try {
             Yii::app()->getDb()->setActive(true);
             $cmd = Yii::app()->getDb()->createCommand($sql);
             $cmd->prepare();
             $cmd->execute();
             $response->addNotification('success', Yii::t('core', 'successKillProcess', array('{id}' => $id)), null, $sql);
         } catch (CDbException $ex) {
             $ex = new DbException($cmd);
             $response->addNotification('error', Yii::t('core', 'errorKillProcess', array('{id}' => $id)), $ex->getText(), $sql);
         }
     }
     $this->sendJSON($response);
 }
开发者ID:cebe,项目名称:chive,代码行数:23,代码来源:InformationController.php

示例2: 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);
 }
开发者ID:cebe,项目名称:chive,代码行数:28,代码来源:SchemaController.php

示例3: 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);
 }
开发者ID:cebe,项目名称:chive,代码行数:32,代码来源:TableController.php

示例4: actionUpdate

 /**
  * Updates a view.
  */
 public function actionUpdate()
 {
     $this->layout = false;
     $view = View::model()->findByPk(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->view));
     if (isset($_POST['query'])) {
         $query = $_POST['query'];
         $cmd = $this->db->createCommand($query);
         try {
             $cmd->prepare();
             $cmd->execute();
             $response = new AjaxResponse();
             $response->addNotification('success', Yii::t('core', 'successAlterView', array('{view}' => $view->TABLE_NAME)), null, $query);
             $response->refresh = true;
             $this->sendJSON($response);
         } catch (CDbException $ex) {
             $errorInfo = $cmd->getPdoStatement()->errorInfo();
             $view->addError(null, Yii::t('core', 'sqlErrorOccured', array('{errno}' => $errorInfo[1], '{errmsg}' => $errorInfo[2])));
         }
     } else {
         $query = $view->getAlterView();
     }
     CHtml::generateRandomIdPrefix();
     $this->render('form', array('view' => $view, 'query' => $query));
 }
开发者ID:cebe,项目名称:chive,代码行数:27,代码来源:ViewController.php

示例5: actionExecute

 /**
  * Execute a bookmark
  */
 public function actionExecute()
 {
     $id = Yii::app()->getRequest()->getParam('id');
     $response = new AjaxResponse();
     $response->refresh = true;
     $bookmark = Yii::app()->user->settings->get('bookmarks', 'database', $this->schema, 'id', $id);
     try {
         $cmd = new CDbCommand($this->db, $bookmark['query']);
         $cmd->execute();
         $response->addNotification('success', Yii::t('core', 'successExecuteBookmark', array('{name}' => $bookmark['name'])), null, $bookmark['query']);
     } catch (Exception $ex) {
         $response->addNotification('error', $ex->getMessage(), $bookmark['query'], array('isSticky' => true));
     }
     $this->sendJSON($response);
 }
开发者ID:cebe,项目名称:chive,代码行数:18,代码来源:BookmarkController.php

示例6: actionDrop

 public function actionDrop()
 {
     $columns = (array) $_POST['column'];
     $response = new AjaxResponse();
     $droppedColumns = $droppedSqls = array();
     foreach ($columns as $column) {
         $pk = array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table, 'COLUMN_NAME' => $column);
         $column = Column::model()->findByPk($pk);
         $column->throwExceptions = true;
         try {
             $sql = $column->delete();
             $droppedColumns[] = $column->COLUMN_NAME;
             $droppedSqls[] = $sql;
         } catch (DbException $ex) {
             $response->addNotification('error', Yii::t('core', 'errorDropColumn', array('{col}' => $column->COLUMN_NAME)), null, $ex->getText());
             $response->refresh = true;
         }
     }
     $count = count($droppedColumns);
     if ($count > 0) {
         $response->addNotification('success', Yii::t('core', 'successDropColumn', array($count, '{col}' => $droppedColumns[0], '{colCount}' => $count)), $count > 1 ? implode(', ', $droppedColumns) : null, implode("\n", $droppedSqls));
     }
     $this->sendJSON($response);
 }
开发者ID:cebe,项目名称:chive,代码行数:24,代码来源:ColumnController.php

示例7: run

    public function run()
    {
        $response = new AjaxResponse();
        $profiling = Yii::app()->user->settings->get('profiling');
        try {
            $sqlQuery = new SqlQuery($this->query);
        } catch (SQPException $ex) {
            $response->addNotification('error', Yii::t('core', 'errorExecuteQuery'), $ex->getMessage());
            $this->response = $response;
            return;
        }
        if (!$this->query) {
            $this->query = $this->getDefaultQuery();
            $queries = (array) $this->query;
        } else {
            if ($profiling) {
                $cmd = $this->db->createCommand('FLUSH STATUS');
                $cmd->execute();
                $cmd = $this->db->createCommand('SET PROFILING = 1');
                $cmd->execute();
            }
            $splitter = new SqlSplitter($this->query);
            $queries = $splitter->getQueries();
        }
        if ($this->execute) {
            $queryCount = count($queries);
            $i = 1;
            foreach ($queries as $query) {
                try {
                    $sqlQuery = new SqlQuery($query);
                } catch (SQPException $ex) {
                    $response->addNotification('error', Yii::t('core', 'errorExecuteQuery'), $ex->getMessage());
                    break;
                }
                $type = $sqlQuery->getType();
                $this->table = $sqlQuery->getTable();
                $this->tables = $sqlQuery->getTables();
                $this->singleTableSelect = count($this->tables) == 1;
                // SELECT
                if ($type == "select") {
                    // Pagination
                    $pages = new Pagination();
                    $pages->route = $this->route;
                    $pageSize = $pages->setupPageSize('pageSize', 'schema.table.browse');
                    // Sorting
                    $sort = new Sort($this->db);
                    $sort->multiSort = false;
                    $sort->route = $this->route;
                    $sqlQuery->applyCalculateFoundRows();
                    $limit = $sqlQuery->getLimit();
                    $order = $sqlQuery->getOrder();
                    // Apply sort
                    if ($sort->getOrder()) {
                        $sqlQuery->applySort($sort->getOrder(), true);
                    }
                    if (isset($_REQUEST['page'])) {
                        $offset = $_REQUEST['page'] * $pageSize - $pageSize;
                        $sqlQuery->applyLimit($pageSize, $offset, true);
                    }
                    // Set pagesize from query limit
                    if ($limit && !isset($_REQUEST[$pages->pageSizeVar])) {
                        $_REQUEST[$pages->pageSizeVar] = $limit['length'];
                        $pageSize = $pages->setupPageSize('pageSize', 'schema.table.browse');
                        $offset = $limit['start'];
                    } elseif (!$limit) {
                        $offset = 0;
                        $sqlQuery->applyLimit($pageSize, $offset, true);
                    } elseif (isset($_REQUEST[$pages->pageSizeVar])) {
                        $pageSize = $pages->setupPageSize('pageSize', 'schema.table.browse');
                        $offset = 0;
                        $sqlQuery->applyLimit($pageSize, $offset, true);
                    }
                    $this->start = (int) $offset;
                } elseif ($type == "insert" || $type == "update" || $type == "delete") {
                    #predie("insert / update / delete statement");
                    $response->refresh = true;
                } elseif ($type == "show") {
                    // show create table etc.
                } elseif ($type == "explain") {
                } elseif ($type == "analyze" || $type == "optimize" || $type == "repair" || $type == "check") {
                    // Table functions
                } elseif ($type == "use") {
                    $name = $sqlQuery->getDatabase();
                    if ($queryCount == 1 && $name && $this->schema != $name) {
                        $response->redirectUrl = Yii::app()->baseUrl . '/schema/' . $name . '#sql';
                        $response->addNotification('success', Yii::t('core', 'successChangeDatabase', array('{name}' => $name)));
                    }
                } elseif ($type == "create") {
                    $response->reload = true;
                } elseif ($type == "drop") {
                    $response->reload = true;
                }
                $this->executedQueries[] = $sqlQuery->getQuery();
                $this->originalQueries[] = $sqlQuery->getOriginalQuery();
                if ($type == "select") {
                    $pages->postVars = $sort->postVars = array('query' => $sqlQuery->getOriginalQuery());
                }
                // Prepare query for execution
                $cmd = $this->db->createCommand($sqlQuery->getQuery());
                $cmd->prepare();
//.........这里部分代码省略.........
开发者ID:cebe,项目名称:chive,代码行数:101,代码来源:BrowsePage.php

示例8: actionDropSchema

 public function actionDropSchema()
 {
     $response = new AjaxResponse();
     $response->refresh = true;
     $schemata = (array) $_POST['schemata'];
     $droppedSchemata = $droppedSqls = array();
     foreach ($schemata as $schema) {
         $schemaObj = SchemaPrivilege::model()->findByPk(array('Host' => $this->host, 'User' => $this->user, 'Db' => $schema));
         try {
             $sql = $schemaObj->delete();
             $droppedSchemata[] = $schema;
             $droppedSqls[] = $sql;
         } catch (DbException $ex) {
             $response->addNotification('error', Yii::t('core', 'errorDropSchemaSpecificPrivileges', array('{user}' => $user)), $ex->getText());
         }
     }
     $count = count($droppedSchemata);
     if ($count > 0) {
         $tArgs = array($count, '{user}' => $this->user, '{host}' => $this->host, '{schema}' => $droppedSchemata[0], '{schemaCount}' => $count);
         $response->addNotification('success', Yii::t('core', 'successDropSchemaSpecificPrivileges', $tArgs), $count > 1 ? implode(', ', $droppedSchemata) : null);
     }
     $this->sendJSON($response);
 }
开发者ID:cebe,项目名称:chive,代码行数:23,代码来源:PrivilegesController.php

示例9: 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);
 }
开发者ID:cebe,项目名称:chive,代码行数:17,代码来源:IndexController.php

示例10: 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);
 }
开发者ID:cebe,项目名称:chive,代码行数:51,代码来源:ImportPage.php

示例11: actionUpdate

 /**
  * Updates a routine.
  */
 public function actionUpdate()
 {
     $routine = Routine::model()->findByPk(array('ROUTINE_SCHEMA' => $this->schema, 'ROUTINE_NAME' => $this->routine));
     if (is_null($routine)) {
         $routine = new Routine();
         $routine->ROUTINE_TYPE = $_POST['type'];
     }
     $type = strtolower($routine->ROUTINE_TYPE);
     if (isset($_POST['query'])) {
         $currentRoutine = $routine->getCreateRoutine();
         $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', 'successAlterRoutine', array('{routine}' => $routine->ROUTINE_NAME)), null, $query);
             $response->refresh = true;
             $this->sendJSON($response);
         } catch (CDbException $ex) {
             $errorInfo = $cmd->getPdoStatement()->errorInfo();
             $routine->addError(null, Yii::t('core', 'sqlErrorOccured', array('{errno}' => $errorInfo[1], '{errmsg}' => $errorInfo[2])));
             $this->restoreCurrentRoutine($currentRoutine);
         }
     } else {
         $query = 'DROP ' . strtoupper($routine->ROUTINE_TYPE) . ' ' . $this->db->quoteTableName($routine->ROUTINE_NAME) . self::$delimiter . "\n" . $routine->getCreateRoutine();
     }
     CHtml::generateRandomIdPrefix();
     $this->render('form', array('routine' => $routine, 'type' => $type, 'query' => $query));
 }
开发者ID:cebe,项目名称:chive,代码行数:39,代码来源:RoutineController.php

示例12: 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));
 }
开发者ID:cebe,项目名称:chive,代码行数:35,代码来源:TriggerController.php


注:本文中的AjaxResponse::addNotification方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。