本文整理汇总了PHP中SqlQuery::returnsResultSet方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlQuery::returnsResultSet方法的具体用法?PHP SqlQuery::returnsResultSet怎么用?PHP SqlQuery::returnsResultSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlQuery
的用法示例。
在下文中一共展示了SqlQuery::returnsResultSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
//.........这里部分代码省略.........
} 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();
if ($this->hasResultSet = $sqlQuery->returnsResultSet() !== false) {
try {
// Fetch data
$start = microtime(true);
$data = $cmd->queryAll();
$time = round(microtime(true) - $start, 6);
SqlUtil::FixTable($data);
if ($type == 'select') {
$total = (int) $this->db->createCommand('SELECT FOUND_ROWS()')->queryScalar();
$pages->setItemCount($total);
$this->total = $total;
$keyData = array();
}
$columns = array();
// Fetch column headers
if (isset($data[0])) {
$columns = array_keys($data[0]);
}
$isSent = true;
$this->lastResultSetQuery = $sqlQuery->getOriginalQuery();
} catch (CDbException $ex) {
$ex = new DbException($cmd);
$response->addNotification('error', Yii::t('core', 'errorExecuteQuery'), $ex->getText(), $ex->getSql());
}
} else {
try {
// Measure time
$start = microtime(true);
$result = $cmd->execute();
$time = round(microtime(true) - $start, 6);
$response->addNotification('success', Yii::t('core', 'successExecuteQuery'), Yii::t('core', 'affectedRowsQueryTime', array($result, '{rows}' => $result, '{time}' => $time)), $sqlQuery->getQuery());
} catch (CDbException $ex) {
$dbException = new DbException($cmd);