mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Updated DBCubrid pagination to use new Query class.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8439 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
0cd318fcf5
commit
d51e931527
3 changed files with 26 additions and 21 deletions
|
|
@ -665,24 +665,24 @@
|
|||
|
||||
|
||||
function getSelectSql($query){
|
||||
$select = $query->getSelect();
|
||||
$select = $query->getSelectString();
|
||||
if($select == '') return new Object(-1, "Invalid query");
|
||||
$select = 'SELECT ' .$select;
|
||||
|
||||
$from = $query->getFrom();
|
||||
$from = $query->getFromString();
|
||||
if($from == '') return new Object(-1, "Invalid query");
|
||||
$from = ' FROM '.$from;
|
||||
|
||||
$where = $query->getWhere();
|
||||
$where = $query->getWhereString();
|
||||
if($where != '') $where = ' WHERE ' . $where;
|
||||
|
||||
$groupBy = $query->getGroupBy();
|
||||
$groupBy = $query->getGroupByString();
|
||||
if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
|
||||
|
||||
$orderBy = $query->getOrderBy();
|
||||
$orderBy = $query->getOrderByString();
|
||||
if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
|
||||
|
||||
$limit = $query->getLimit();
|
||||
$limit = $query->getLimitString();
|
||||
if($limit != '') $limit = ' LIMIT ' . $limit;
|
||||
|
||||
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
||||
|
|
@ -713,9 +713,9 @@
|
|||
}else return;
|
||||
}
|
||||
|
||||
if ($limit && $output->limit->isPageHandler()) {
|
||||
$count_query = sprintf('select count(*) as "count" %s %s', $from, $where);
|
||||
if (count($output->groups)) {
|
||||
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
|
||||
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($queryObject->getWhereString() === '' ? '' : ' WHERE '. $queryObject->getWhereString()));
|
||||
if ($queryObject->getGroupByString() != '') {
|
||||
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
|
||||
}
|
||||
|
||||
|
|
@ -726,10 +726,10 @@
|
|||
|
||||
// total pages
|
||||
if ($total_count) {
|
||||
$total_page = (int) (($total_count - 1) / $output->limit->list_count) + 1;
|
||||
$total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1;
|
||||
} else $total_page = 1;
|
||||
|
||||
$virtual_no = $total_count - ($output->limit->page - 1) * $output->limit->list_count;
|
||||
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
|
||||
while ($tmp = cubrid_fetch ($result, CUBRID_OBJECT)) {
|
||||
if ($tmp) {
|
||||
foreach ($tmp as $k => $v) {
|
||||
|
|
@ -742,9 +742,9 @@
|
|||
$buff = new Object ();
|
||||
$buff->total_count = $total_count;
|
||||
$buff->total_page = $total_page;
|
||||
$buff->page = $output->limit->page;
|
||||
$buff->page = $queryObject->getLimit()->page;
|
||||
$buff->data = $data;
|
||||
$buff->page_navigation = new PageHandler ($total_count, $total_page, $output->limit->page, $output->limit->page_count);
|
||||
$buff->page_navigation = new PageHandler ($total_count, $total_page, $queryObject->getLimit()->page, $queryObject->getLimit()->page_count);
|
||||
}else{
|
||||
$data = $this->_fetch ($result);
|
||||
$buff = new Object ();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
var $conditions;
|
||||
var $groups;
|
||||
var $orderby;
|
||||
var $limit;
|
||||
|
||||
|
||||
function setQueryId($queryID){
|
||||
|
|
@ -105,7 +106,7 @@
|
|||
return $this->action;
|
||||
}
|
||||
|
||||
function getSelect(){
|
||||
function getSelectString(){
|
||||
$select = '';
|
||||
foreach($this->columns as $column){
|
||||
if($column->show())
|
||||
|
|
@ -116,7 +117,7 @@
|
|||
return $select;
|
||||
}
|
||||
|
||||
function getFrom(){
|
||||
function getFromString(){
|
||||
$from = '';
|
||||
$simple_table_count = 0;
|
||||
foreach($this->tables as $table){
|
||||
|
|
@ -131,7 +132,7 @@
|
|||
|
||||
}
|
||||
|
||||
function getWhere(){
|
||||
function getWhereString(){
|
||||
$where = '';
|
||||
if(count($this->conditions) > 0){
|
||||
foreach($this->conditions as $conditionGroup){
|
||||
|
|
@ -143,14 +144,14 @@
|
|||
return $where;
|
||||
}
|
||||
|
||||
function getGroupBy(){
|
||||
function getGroupByString(){
|
||||
$groupBy = '';
|
||||
if($this->groups) if($this->groups[0] !== "")
|
||||
$groupBy = implode(', ', $this->groups);
|
||||
return $groupBy;
|
||||
}
|
||||
|
||||
function getOrderBy(){
|
||||
function getOrderByString(){
|
||||
if(count($this->orderby) === 0) return '';
|
||||
$orderBy = '';
|
||||
foreach($this->orderby as $order){
|
||||
|
|
@ -161,6 +162,10 @@
|
|||
}
|
||||
|
||||
function getLimit(){
|
||||
return $this->limit;
|
||||
}
|
||||
|
||||
function getLimitString(){
|
||||
$limit = '';
|
||||
if(count($this->limit) > 0){
|
||||
$limit = '';
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
* 2: output execute time, Request/Response info
|
||||
* 4: output DB query history
|
||||
**/
|
||||
if(!defined('__DEBUG__')) define('__DEBUG__', 0);
|
||||
if(!defined('__DEBUG__')) define('__DEBUG__', 4);
|
||||
|
||||
/**
|
||||
* @brief output location of debug message
|
||||
|
|
@ -82,14 +82,14 @@
|
|||
* = 0: leave a log when the slow query takes over specified seconds
|
||||
* Log file is saved as ./files/_db_slow_query.php file
|
||||
**/
|
||||
if(!defined('__LOG_SLOW_QUERY__')) define('__LOG_SLOW_QUERY__', 0);
|
||||
if(!defined('__LOG_SLOW_QUERY__')) define('__LOG_SLOW_QUERY__', 1);
|
||||
|
||||
/**
|
||||
* @brief Leave DB query information
|
||||
* 0: Do not add information to the query
|
||||
* 1: Comment the XML Query ID
|
||||
**/
|
||||
if(!defined('__DEBUG_QUERY__')) define('__DEBUG_QUERY__', 0);
|
||||
if(!defined('__DEBUG_QUERY__')) define('__DEBUG_QUERY__', 1);
|
||||
|
||||
/**
|
||||
* @brief option to enable/disable a compression feature using ob_gzhandler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue