mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +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
|
|
@ -1,3 +1,4 @@
|
|||
<<<<<<< .working
|
||||
<?php
|
||||
|
||||
class Query extends Object {
|
||||
|
|
@ -93,6 +94,61 @@
|
|||
|
||||
$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){
|
||||
$this->subquery = $subquery;
|
||||
|
|
@ -204,6 +260,7 @@
|
|||
}
|
||||
|
||||
|
||||
<<<<<<< .working
|
||||
$valuesList = '';
|
||||
foreach($this->columns as $column){
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue