mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-12 07:11:42 +09:00
add "limit" navigation control to xml query and db classes
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8395 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
4d2d18b53b
commit
750733936b
6 changed files with 65 additions and 8 deletions
|
|
@ -316,6 +316,7 @@
|
|||
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/DBParser.class.php');
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/argument/Argument.class.php');
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/argument/ConditionArgument.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/Expression.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/SelectExpression.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
|
||||
|
|
@ -326,6 +327,7 @@
|
|||
require_once(_XE_PATH_.'classes/db/queryparts/condition/Condition.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/StarExpression.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/queryparts/order/OrderByColumn.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/queryparts/limit/Limit.class.php');
|
||||
|
||||
|
||||
$output = include($cache_file);
|
||||
|
|
|
|||
|
|
@ -795,9 +795,13 @@
|
|||
}
|
||||
$orderBy = substr($orderBy, 0, -2);
|
||||
}
|
||||
$limit = '';
|
||||
if(count($output->limit) > 0){
|
||||
$limit = 'limit ';
|
||||
$limit .= $output->limit->toString();
|
||||
}
|
||||
|
||||
|
||||
$query = $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy;
|
||||
$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 .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
|
||||
|
|
|
|||
16
classes/db/queryparts/limit/Limit.class.php
Normal file
16
classes/db/queryparts/limit/Limit.class.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
class Limit {
|
||||
var $start;
|
||||
var $end;
|
||||
|
||||
function Limit($page, $list_count){
|
||||
$this->start = ($page-1)*$list_count;
|
||||
$this->end = $list_count;
|
||||
}
|
||||
|
||||
function toString(){
|
||||
return $this->start . ' , ' . $this->end;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -133,6 +133,7 @@ class QueryParser {
|
|||
$buff .= '$output->conditions = '.$conditions->toString() .';'.PHP_EOL;
|
||||
$buff .= '$output->groups = ' . $groups->toString() . ';';
|
||||
$buff .= '$output->orderby = ' . $navigation->getOrderByString() .';';
|
||||
$buff .= $navigation->getLimitString()?'$output->limit = ' . $navigation->getLimitString() .';':"";
|
||||
|
||||
return "<?php if(!defined('__ZBXE__')) exit();\n"
|
||||
. sprintf('$output->query_id = "%s";%s', $this->query_id, "\n")
|
||||
|
|
|
|||
27
classes/xml/xmlquery/tags/navigation/LimitTag.class.php
Normal file
27
classes/xml/xmlquery/tags/navigation/LimitTag.class.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
class LimitTag {
|
||||
var $arguments;
|
||||
var $page;
|
||||
var $page_count;
|
||||
var $list_count;
|
||||
|
||||
function LimitTag($index){
|
||||
$this->page = $index->page->attrs;
|
||||
$this->page_count = $index->page_count->attrs;
|
||||
$this->list_count = $index->list_count->attrs;
|
||||
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||
$this->arguments[] = new QueryArgument($index->page);
|
||||
$this->arguments[] = new QueryArgument($index->list_count);
|
||||
}
|
||||
|
||||
function toString(){
|
||||
return sprintf("new Limit(\$%s_argument->getValue(), \$%s_argument->getValue())", $this->page->var, $this->list_count->var);
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
return $this->arguments;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/tags/navigation/IndexTag.class.php');
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/tags/navigation/LimitTag.class.php');
|
||||
|
||||
class NavigationTag {
|
||||
var $order;
|
||||
var $list_count;
|
||||
var $page_count;
|
||||
var $page;
|
||||
var $limit;
|
||||
|
||||
function NavigationTag($xml_navigation){
|
||||
$this->order = array();
|
||||
|
|
@ -18,6 +20,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
if($xml_navigation->page->attrs && $xml_navigation->list_count->attrs)
|
||||
$this->limit = new LimitTag($xml_navigation);
|
||||
|
||||
$list_count = $xml_navigation->list_count->attrs;
|
||||
$this->list_count = $list_count;
|
||||
|
||||
|
|
@ -40,7 +45,8 @@
|
|||
}
|
||||
|
||||
function getLimitString(){
|
||||
|
||||
if ($this->limit) return $this->limit->toString();
|
||||
else return "";
|
||||
}
|
||||
|
||||
function getArguments(){
|
||||
|
|
@ -48,6 +54,7 @@
|
|||
foreach($this->order as $order){
|
||||
$arguments = array_merge($order->getArguments(), $arguments);
|
||||
}
|
||||
if($this->limit) $arguments = array_merge($this->limit->getArguments(), $arguments);
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue