本文整理汇总了PHP中SqlQuery::getOriginalQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlQuery::getOriginalQuery方法的具体用法?PHP SqlQuery::getOriginalQuery怎么用?PHP SqlQuery::getOriginalQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlQuery
的用法示例。
在下文中一共展示了SqlQuery::getOriginalQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
//.........这里部分代码省略.........