mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-31 09:09:59 +09:00
Fix condition/ConditionGroup.class.php when all conditions have no value.
Add page navigation mechanism. git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8399 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
750733936b
commit
0b78e26357
4 changed files with 66 additions and 11 deletions
|
|
@ -802,15 +802,59 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
$query = $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
||||||
|
|
||||||
//$query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, //$groupby_query.$orderby_query);
|
//$query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, //$groupby_query.$orderby_query);
|
||||||
//$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
|
//$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
|
||||||
$result = $this->_query ($query);
|
$result = $this->_query ($query);
|
||||||
if ($this->isError ()) return;
|
if ($this->isError ()) {
|
||||||
$data = $this->_fetch ($result);
|
if ($limit && $output->limit->isPageHandler()){
|
||||||
|
$buff = new Object ();
|
||||||
|
$buff->total_count = 0;
|
||||||
|
$buff->total_page = 0;
|
||||||
|
$buff->page = 1;
|
||||||
|
$buff->data = array ();
|
||||||
|
$buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
|
||||||
|
return $buff;
|
||||||
|
}else return;
|
||||||
|
}
|
||||||
|
|
||||||
$buff = new Object ();
|
if ($limit && $output->limit->isPageHandler()) {
|
||||||
$buff->data = $data;
|
$count_query = sprintf('select count(*) as "count" %s %s', $from, $where);
|
||||||
|
if (count($output->groups)) {
|
||||||
|
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
|
||||||
|
$result_count = $this->_query($count_query);
|
||||||
|
$count_output = $this->_fetch($result_count);
|
||||||
|
$total_count = (int)$count_output->count;
|
||||||
|
|
||||||
|
// total pages
|
||||||
|
if ($total_count) {
|
||||||
|
$total_page = (int) (($total_count - 1) / $output->limit->list_count) + 1;
|
||||||
|
} else $total_page = 1;
|
||||||
|
|
||||||
|
$virtual_no = $total_count - ($output->limit->page - 1) * $output->limit->list_count;
|
||||||
|
while ($tmp = cubrid_fetch ($result, CUBRID_OBJECT)) {
|
||||||
|
if ($tmp) {
|
||||||
|
foreach ($tmp as $k => $v) {
|
||||||
|
$tmp->{$k} = rtrim($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data[$virtual_no--] = $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
$buff = new Object ();
|
||||||
|
$buff->total_count = $total_count;
|
||||||
|
$buff->total_page = $total_page;
|
||||||
|
$buff->page = $output->limit->page;
|
||||||
|
$buff->data = $data;
|
||||||
|
$buff->page_navigation = new PageHandler ($total_count, $total_page, $output->limit->page, $output->limit->page_count);
|
||||||
|
}else{
|
||||||
|
$data = $this->_fetch ($result);
|
||||||
|
$buff = new Object ();
|
||||||
|
$buff->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
$cond_indx++;
|
$cond_indx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If the group has no conditions in it, return ''
|
||||||
|
if($cond_indx === 0) return '';
|
||||||
|
|
||||||
if($this->pipe !== "")
|
if($this->pipe !== "")
|
||||||
$group .= ')';
|
$group .= ')';
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
class Limit {
|
class Limit {
|
||||||
var $start;
|
var $start;
|
||||||
var $end;
|
var $list_count;
|
||||||
|
var $page_count;
|
||||||
function Limit($page, $list_count){
|
var $page;
|
||||||
|
|
||||||
|
function Limit($page, $list_count, $page_count){
|
||||||
$this->start = ($page-1)*$list_count;
|
$this->start = ($page-1)*$list_count;
|
||||||
$this->end = $list_count;
|
$this->list_count = $list_count;
|
||||||
|
$this->page_count = $page_count;
|
||||||
|
$this->page = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPageHandler(){//in case you choose to use query limit in other cases than page select
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString(){
|
||||||
return $this->start . ' , ' . $this->end;
|
return $this->start . ' , ' . $this->list_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,11 @@
|
||||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||||
$this->arguments[] = new QueryArgument($index->page);
|
$this->arguments[] = new QueryArgument($index->page);
|
||||||
$this->arguments[] = new QueryArgument($index->list_count);
|
$this->arguments[] = new QueryArgument($index->list_count);
|
||||||
|
$this->arguments[] = new QueryArgument($index->page_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString(){
|
||||||
return sprintf("new Limit(\$%s_argument->getValue(), \$%s_argument->getValue())", $this->page->var, $this->list_count->var);
|
return sprintf("new Limit(\$%s_argument->getValue(), \$%s_argument->getValue(), \$%s_argument->getValue())", $this->page->var, $this->list_count->var, $this->page_count->var);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments(){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue