mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 04:24:14 +09:00
reverse merge from 1.6.0 (r10563)
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10711 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
09dc853b4d
commit
f0aa085c94
9 changed files with 292 additions and 53 deletions
|
|
@ -784,7 +784,7 @@
|
||||||
$count_query .= (__DEBUG_QUERY__&1 && $queryObject->queryID)?sprintf (' '.$this->comment_syntax, $queryObject->queryID):'';
|
$count_query .= (__DEBUG_QUERY__&1 && $queryObject->queryID)?sprintf (' '.$this->comment_syntax, $queryObject->queryID):'';
|
||||||
$result = $this->_query($count_query, $connection);
|
$result = $this->_query($count_query, $connection);
|
||||||
$count_output = $this->_fetch($result);
|
$count_output = $this->_fetch($result);
|
||||||
$total_count = (int)(isset($count_output->count) ? $count_output->count : NULL);
|
$total_count = (int)(isset($count_output->output) ? $count_output->count : NULL);
|
||||||
|
|
||||||
$list_count = $limit->list_count->getValue();
|
$list_count = $limit->list_count->getValue();
|
||||||
if (!$list_count) $list_count = 20;
|
if (!$list_count) $list_count = 20;
|
||||||
|
|
@ -834,9 +834,8 @@
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getParser($force = FALSE){
|
function getParser($force = FALSE){
|
||||||
$dbParser = new DBParser('"', '"', $this->prefix);
|
return new DBParser('"', '"', $this->prefix);
|
||||||
return $dbParser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) {
|
function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) {
|
||||||
|
|
|
||||||
|
|
@ -540,9 +540,8 @@
|
||||||
else return $this->queryPageLimit($queryObject, $result, $connection);
|
else return $this->queryPageLimit($queryObject, $result, $connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getParser($force = FALSE){
|
function getParser($force = FALSE){
|
||||||
$dbParser = new DBParser("[", "]", $this->prefix);
|
return new DBParser("[", "]", $this->prefix);
|
||||||
return $dbParser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryError($queryObject){
|
function queryError($queryObject){
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,17 @@ class DBMysql extends DB {
|
||||||
$default = $column->attrs->default;
|
$default = $column->attrs->default;
|
||||||
$auto_increment = $column->attrs->auto_increment;
|
$auto_increment = $column->attrs->auto_increment;
|
||||||
|
|
||||||
|
foreach($columns as $column) {
|
||||||
|
$name = $column->attrs->name;
|
||||||
|
$type = $column->attrs->type;
|
||||||
|
$size = $column->attrs->size;
|
||||||
|
$notnull = $column->attrs->notnull;
|
||||||
|
$primary_key = $column->attrs->primary_key;
|
||||||
|
$index = $column->attrs->index;
|
||||||
|
$unique = $column->attrs->unique;
|
||||||
|
$default = $column->attrs->default;
|
||||||
|
$auto_increment = $column->attrs->auto_increment;
|
||||||
|
|
||||||
$column_schema[] = sprintf('`%s` %s%s %s %s %s',
|
$column_schema[] = sprintf('`%s` %s%s %s %s %s',
|
||||||
$name,
|
$name,
|
||||||
$this->column_type[$type],
|
$this->column_type[$type],
|
||||||
|
|
@ -369,13 +380,21 @@ class DBMysql extends DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle the insertAct
|
* @brief Handle selectAct
|
||||||
|
*
|
||||||
|
* In order to get a list of pages easily when selecting \n
|
||||||
|
* it supports a method as navigation
|
||||||
**/
|
**/
|
||||||
function _executeInsertAct($queryObject, $with_values = true) {
|
function _executeSelectAct($queryObject, $connection = null, $with_values = true) {
|
||||||
$query = $this->getInsertSql($queryObject, $with_values, true);
|
$limit = $queryObject->getLimit();
|
||||||
if(is_a($query, 'Object')) return;
|
$result = NULL;
|
||||||
return $this->_query($query);
|
if ($limit && $limit->isPageHandler())
|
||||||
}
|
return $this->queryPageLimit($queryObject, $result, $connection, $with_values);
|
||||||
|
else {
|
||||||
|
$query = $this->getSelectSql($queryObject, $with_values);
|
||||||
|
if (is_a($query, 'Object'))
|
||||||
|
return;
|
||||||
|
$query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle updateAct
|
* @brief Handle updateAct
|
||||||
|
|
@ -429,6 +448,9 @@ class DBMysql extends DB {
|
||||||
return mysql_insert_id($connection);
|
return mysql_insert_id($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParser($force = FALSE){
|
||||||
|
return new DBParser('`', '`', $this->prefix);
|
||||||
|
}
|
||||||
function db_fetch_object(&$result)
|
function db_fetch_object(&$result)
|
||||||
{
|
{
|
||||||
return mysql_fetch_object($result);
|
return mysql_fetch_object($result);
|
||||||
|
|
@ -438,25 +460,30 @@ class DBMysql extends DB {
|
||||||
return mysql_free_result($result);
|
return mysql_free_result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getParser($force = FALSE){
|
function queryPageLimit($queryObject, $result, $connection, $with_values = true){
|
||||||
$dbParser = new DBParser('`', '`', $this->prefix);
|
$limit = $queryObject->getLimit();
|
||||||
return $dbParser;
|
// Total count
|
||||||
|
$temp_where = $queryObject->getWhereString($with_values, false);
|
||||||
|
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '. $temp_where));
|
||||||
|
|
||||||
|
// Check for distinct query and if found update count query structure
|
||||||
|
$temp_select = $queryObject->getSelectString($with_values);
|
||||||
|
$uses_distinct = false;
|
||||||
|
if(strpos(strtolower($temp_select), "distinct") !== false) {
|
||||||
|
$count_query = sprintf('select %s %s %s', 'FROM ' . $queryObject->getFromString($with_values), $temp_select, ($temp_where === '' ? '' : ' WHERE '. $temp_where));
|
||||||
|
$uses_distinct = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryError($queryObject){
|
// If query uses grouping or distinct, count from original select
|
||||||
$limit = $queryObject->getLimit();
|
if ($queryObject->getGroupByString() != '' || $uses_distinct) {
|
||||||
if ($limit && $limit->isPageHandler()){
|
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$count_query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
|
||||||
|
$result_count = $this->_query($count_query, $connection);
|
||||||
|
$count_output = $this->_fetch($result_count);
|
||||||
|
$total_count = (int)(isset($count_output->count) ? $count_output->count : NULL);
|
||||||
|
|
||||||
function queryPageLimit($queryObject, $result, $connection, $with_values = true){
|
function queryPageLimit($queryObject, $result, $connection, $with_values = true){
|
||||||
$limit = $queryObject->getLimit();
|
$limit = $queryObject->getLimit();
|
||||||
// Total count
|
// Total count
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<<<<<<< .working
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Query extends Object {
|
class Query extends Object {
|
||||||
|
|
@ -93,6 +94,61 @@
|
||||||
|
|
||||||
$this->tables = $tables;
|
$this->tables = $tables;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Query extends Object {
|
||||||
|
var $queryID;
|
||||||
|
var $action;
|
||||||
|
var $priority;
|
||||||
|
|
||||||
|
var $columns;
|
||||||
|
var $tables;
|
||||||
|
var $conditions;
|
||||||
|
var $groups;
|
||||||
|
var $orderby;
|
||||||
|
var $limit;
|
||||||
|
|
||||||
|
var $arguments = null;
|
||||||
|
|
||||||
|
var $columnList = null;
|
||||||
|
|
||||||
|
var $_orderByString;
|
||||||
|
|
||||||
|
function Query($queryID = null
|
||||||
|
, $action = null
|
||||||
|
, $columns = null
|
||||||
|
, $tables = null
|
||||||
|
, $conditions = null
|
||||||
|
, $groups = null
|
||||||
|
, $orderby = null
|
||||||
|
, $limit = null
|
||||||
|
, $priority = null){
|
||||||
|
$this->queryID = $queryID;
|
||||||
|
$this->action = $action;
|
||||||
|
$this->priority = $priority;
|
||||||
|
|
||||||
|
if(!isset($tables)) return;
|
||||||
|
$this->columns = $this->setColumns($columns);
|
||||||
|
$this->tables = $this->setTables($tables);
|
||||||
|
$this->conditions = $this->setConditions($conditions);
|
||||||
|
$this->groups = $this->setGroups($groups);
|
||||||
|
$this->orderby = $this->setOrder($orderby);
|
||||||
|
$this->limit = $this->setLimit($limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function show(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setQueryId($queryID){
|
||||||
|
$this->queryID = $queryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAction($action){
|
||||||
|
$this->action = $action;
|
||||||
|
}
|
||||||
|
>>>>>>> .merge-right.r10563
|
||||||
|
|
||||||
function setSubquery($subquery){
|
function setSubquery($subquery){
|
||||||
$this->subquery = $subquery;
|
$this->subquery = $subquery;
|
||||||
|
|
@ -204,6 +260,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< .working
|
||||||
$valuesList = '';
|
$valuesList = '';
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column){
|
||||||
if($column->show()){
|
if($column->show()){
|
||||||
|
|
@ -359,3 +416,159 @@
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
=======
|
||||||
|
$valuesList = '';
|
||||||
|
foreach($this->columns as $column){
|
||||||
|
if($column->show()){
|
||||||
|
$columnsList .= $column->getColumnName() . ', ';
|
||||||
|
$valuesList .= $column->getValue($with_values) . ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$columnsList = substr($columnsList, 0, -2);
|
||||||
|
$valuesList = substr($valuesList, 0, -2);
|
||||||
|
|
||||||
|
return "($columnsList) \n VALUES ($valuesList)";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTables(){
|
||||||
|
return $this->tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from table_a
|
||||||
|
// from table_a inner join table_b on x=y
|
||||||
|
// from (select * from table a) as x
|
||||||
|
// from (select * from table t) as x inner join table y on y.x
|
||||||
|
function getFromString($with_values = true){
|
||||||
|
$from = '';
|
||||||
|
$simple_table_count = 0;
|
||||||
|
foreach($this->tables as $table){
|
||||||
|
if($table->isJoinTable() || !$simple_table_count) $from .= $table->toString($with_values) . ' ';
|
||||||
|
else $from .= ', '.$table->toString($with_values) . ' ';
|
||||||
|
|
||||||
|
if(is_a($table, 'Subquery')) $from .= $table->getAlias() ? ' as ' . $table->getAlias() . ' ' : ' ';
|
||||||
|
|
||||||
|
$simple_table_count++;
|
||||||
|
}
|
||||||
|
if(trim($from) == '') return '';
|
||||||
|
return $from;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWhereString($with_values = true, $with_optimization = true){
|
||||||
|
$where = '';
|
||||||
|
$condition_count = 0;
|
||||||
|
|
||||||
|
foreach ($this->conditions as $conditionGroup) {
|
||||||
|
if ($condition_count === 0) {
|
||||||
|
$conditionGroup->setPipe("");
|
||||||
|
}
|
||||||
|
$condition_string = $conditionGroup->toString($with_values);
|
||||||
|
$where .= $condition_string;
|
||||||
|
$condition_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($with_optimization &&
|
||||||
|
(strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order'))) {
|
||||||
|
|
||||||
|
if ($condition_count !== 0)
|
||||||
|
$where = '(' . $where . ') ';
|
||||||
|
|
||||||
|
foreach ($this->orderby as $order) {
|
||||||
|
$colName = $order->getColumnName();
|
||||||
|
if (strstr($colName, 'list_order') || strstr($colName, 'update_order')) {
|
||||||
|
$opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and');
|
||||||
|
if ($condition_count === 0)
|
||||||
|
$opt_condition->setPipe("");
|
||||||
|
$where .= $opt_condition->toString($with_values) . ' ';
|
||||||
|
$condition_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim($where);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGroupByString(){
|
||||||
|
$groupBy = '';
|
||||||
|
if($this->groups) if($this->groups[0] !== "")
|
||||||
|
$groupBy = implode(', ', $this->groups);
|
||||||
|
return $groupBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOrderByString(){
|
||||||
|
if(!$this->_orderByString){
|
||||||
|
if(count($this->orderby) === 0) return '';
|
||||||
|
$orderBy = '';
|
||||||
|
foreach($this->orderby as $order){
|
||||||
|
$orderBy .= $order->toString() .', ';
|
||||||
|
}
|
||||||
|
$orderBy = substr($orderBy, 0, -2);
|
||||||
|
$this->_orderByString = $orderBy;
|
||||||
|
}
|
||||||
|
return $this->_orderByString;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLimit(){
|
||||||
|
return $this->limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLimitString(){
|
||||||
|
$limit = '';
|
||||||
|
if(count($this->limit) > 0){
|
||||||
|
$limit = '';
|
||||||
|
$limit .= $this->limit->toString();
|
||||||
|
}
|
||||||
|
return $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFirstTableName(){
|
||||||
|
return $this->tables[0]->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getArguments(){
|
||||||
|
if(!isset($this->arguments)){
|
||||||
|
$this->arguments = array();
|
||||||
|
|
||||||
|
// Join table arguments
|
||||||
|
if(count($this->tables) > 0)
|
||||||
|
{
|
||||||
|
foreach($this->tables as $table)
|
||||||
|
{
|
||||||
|
if($table->isJoinTable())
|
||||||
|
{
|
||||||
|
$args = $table->getArguments();
|
||||||
|
if($args) $this->arguments = array_merge($this->arguments, $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Column arguments
|
||||||
|
if(count($this->columns) > 0){ // The if is for delete statements, all others must have columns
|
||||||
|
foreach($this->columns as $column){
|
||||||
|
if($column->show()){
|
||||||
|
$args = $column->getArguments();
|
||||||
|
if($args) $this->arguments = array_merge($this->arguments, $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Condition arguments
|
||||||
|
if(count($this->conditions) > 0)
|
||||||
|
foreach($this->conditions as $conditionGroup){
|
||||||
|
$args = $conditionGroup->getArguments();
|
||||||
|
if(count($args) > 0) $this->arguments = array_merge($this->arguments, $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigation arguments
|
||||||
|
if(count($this->orderby) > 0)
|
||||||
|
foreach($this->orderby as $order){
|
||||||
|
$args = $order->getArguments();
|
||||||
|
if(count($args) > 0) $this->arguments = array_merge($this->arguments, $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->arguments;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>>>>>>>> .merge-right.r10563
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
|
|
||||||
function parse($query_id = NULL, $xml_file = NULL, $cache_file = NULL)
|
function parse($query_id = NULL, $xml_file = NULL, $cache_file = NULL)
|
||||||
{
|
{
|
||||||
$query_parser = &$this->parse_xml_query($query_id, $xml_file, $cache_file);
|
$this->parse_xml_query($query_id, $xml_file, $cache_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getXmlFileContent($xml_file){
|
function getXmlFileContent($xml_file){
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@
|
||||||
var $click_count;
|
var $click_count;
|
||||||
|
|
||||||
function SelectColumnTag($column){
|
function SelectColumnTag($column){
|
||||||
parent::ColumnTag($column->attrs->name);
|
if ($column == "*" || $column->attrs->name == '*')
|
||||||
if(!$this->name) {
|
{
|
||||||
if($column->attrs->var)
|
parent::ColumnTag(NULL);
|
||||||
$this->name = '$' . $column->attrs->var;
|
|
||||||
else
|
|
||||||
$this->name = "*";
|
$this->name = "*";
|
||||||
}
|
}
|
||||||
if($this->name != "*" && substr($this->name, 0, 1) != '$') {
|
else
|
||||||
|
{
|
||||||
|
parent::ColumnTag($column->attrs->name);
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$this->name = $dbParser->parseExpression($this->name);
|
$this->name = $dbParser->parseExpression($this->name);
|
||||||
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
$this->click_count = $column->attrs->click_count;
|
$this->click_count = $column->attrs->click_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getExpressionString(){
|
function getExpressionString(){
|
||||||
if($this->name == '*') return "new StarExpression()";
|
if($this->name == '*') return "new StarExpression()";
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
$this->tables[] = new QueryTag($tag, true);
|
$this->tables[] = new QueryTag($tag, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(isset($indexes) && $indexes && isset($indexes[$tag->attrs->name]))
|
if(isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
|
||||||
$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
|
$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
|
||||||
else
|
else
|
||||||
$this->tables[] = new TableTag($tag);
|
$this->tables[] = new TableTag($tag);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue