issue 2119. supporting php 5.4. db classes.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12686 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-04 09:36:46 +00:00
parent 7fe03148f0
commit 41fdaf00c3
29 changed files with 1846 additions and 798 deletions

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts
@ -6,16 +7,19 @@
*/
class Query extends Object
{
/**
* Query id, defined in query xml file
* @var string
*/
var $queryID;
/**
* DML type, ex) INSERT, DELETE, UPDATE, SELECT
* @var string
*/
var $action;
/**
* priority level ex)LOW_PRIORITY, HIGHT_PRIORITY
* @var string
@ -27,26 +31,31 @@ class Query extends Object
* @var string|array
*/
var $columns;
/**
* table list
* @var string|array
*/
var $tables;
/**
* condition list
* @var string|array
*/
var $conditions;
/**
* group list
* @var string|array
*/
var $groups;
/**
* order list
* @var array
*/
var $orderby;
/**
* limit count
* @var int
@ -85,20 +94,24 @@ class Query extends Object
* @return void
*/
function Query($queryID = NULL
, $action = NULL
, $columns = NULL
, $tables = NULL
, $conditions = NULL
, $groups = NULL
, $orderby = NULL
, $limit = NULL
, $priority = 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;
if(!isset($tables))
{
return;
}
$this->columns = $this->setColumns($columns);
$this->tables = $this->setTables($tables);
$this->conditions = $this->setConditions($conditions);
@ -153,7 +166,10 @@ class Query extends Object
return;
}
if(!is_array($columns)) $columns = array($columns);
if(!is_array($columns))
{
$columns = array($columns);
}
$this->columns = $columns;
}
@ -167,7 +183,10 @@ class Query extends Object
return;
}
if(!is_array($tables)) $tables = array($tables);
if(!is_array($tables))
{
$tables = array($tables);
}
$this->tables = $tables;
}
@ -180,34 +199,58 @@ class Query extends Object
function setConditions($conditions)
{
$this->conditions = array();
if(!isset($conditions) || count($conditions) === 0) return;
if(!is_array($conditions)) $conditions = array($conditions);
if(!isset($conditions) || count($conditions) === 0)
{
return;
}
if(!is_array($conditions))
{
$conditions = array($conditions);
}
foreach($conditions as $conditionGroup)
{
if($conditionGroup->show()) $this->conditions[] = $conditionGroup;
if($conditionGroup->show())
{
$this->conditions[] = $conditionGroup;
}
}
}
function setGroups($groups)
{
if(!isset($groups) || count($groups) === 0) return;
if(!is_array($groups)) $groups = array($groups);
if(!isset($groups) || count($groups) === 0)
{
return;
}
if(!is_array($groups))
{
$groups = array($groups);
}
$this->groups = $groups;
}
function setOrder($order)
{
if(!isset($order) || count($order) === 0) return;
if(!is_array($order)) $order = array($order);
if(!isset($order) || count($order) === 0)
{
return;
}
if(!is_array($order))
{
$order = array($order);
}
$this->orderby = $order;
}
function setLimit($limit = NULL)
{
if(!isset($limit)) return;
if(!isset($limit))
{
return;
}
$this->limit = $limit;
}
@ -217,7 +260,7 @@ class Query extends Object
* @param string|array $columns
* @return Query return Query instance
*/
function select($columns= NULL)
function select($columns = NULL)
{
$this->action = 'select';
$this->setColumns($columns);
@ -278,6 +321,7 @@ class Query extends Object
$this->setLimit($limit);
return $this;
}
// END Fluent interface
function getAction()
@ -287,7 +331,7 @@ class Query extends Object
function getPriority()
{
return $this->priority?'LOW_PRIORITY':'';
return $this->priority ? 'LOW_PRIORITY' : '';
}
/**
@ -304,9 +348,12 @@ class Query extends Object
function getClickCountColumns()
{
$click_count_columns = array();
foreach($this->columns as $column){
foreach($this->columns as $column)
{
if($column->show() && is_a($column, 'ClickCountExpression'))
{
$click_count_columns[] = $column;
}
}
return $click_count_columns;
}
@ -321,12 +368,16 @@ class Query extends Object
foreach($this->columns as $column)
{
if($column->show())
{
if($column->isSubquery())
{
$select[] = $column->toString($with_values) . ' as '. $column->getAlias();
$select[] = $column->toString($with_values) . ' as ' . $column->getAlias();
}
else
{
$select[] = $column->getExpression($with_values);
}
}
}
return trim(implode($select, ', '));
}
@ -341,7 +392,9 @@ class Query extends Object
foreach($this->columns as $column)
{
if($column->show())
{
$update[] = $column->getExpression($with_values);
}
}
return trim(implode($update, ', '));
}
@ -401,14 +454,26 @@ class Query extends Object
$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($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() . ' ' : ' ';
if(is_a($table, 'Subquery'))
{
$from .= $table->getAlias() ? ' as ' . $table->getAlias() . ' ' : ' ';
}
$simple_table_count++;
}
if(trim($from) == '') return '';
if(trim($from) == '')
{
return '';
}
return $from;
}
@ -435,11 +500,13 @@ class Query extends Object
}
if($with_optimization &&
(strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order')))
(strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order')))
{
if($condition_count !== 0)
{
$where = '(' . $where . ') ';
}
foreach($this->orderby as $order)
{
@ -448,7 +515,9 @@ class Query extends Object
{
$opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and');
if($condition_count === 0)
{
$opt_condition->setPipe("");
}
$where .= $opt_condition->toString($with_values) . ' ';
$condition_count++;
}
@ -465,8 +534,13 @@ class Query extends Object
function getGroupByString()
{
$groupBy = '';
if($this->groups) if($this->groups[0] !== "")
$groupBy = implode(', ', $this->groups);
if($this->groups)
{
if($this->groups[0] !== "")
{
$groupBy = implode(', ', $this->groups);
}
}
return $groupBy;
}
@ -478,11 +552,14 @@ class Query extends Object
{
if(!$this->_orderByString)
{
if(count($this->orderby) === 0) return '';
if(count($this->orderby) === 0)
{
return '';
}
$orderBy = '';
foreach($this->orderby as $order)
{
$orderBy .= $order->toString() .', ';
$orderBy .= $order->toString() . ', ';
}
$orderBy = substr($orderBy, 0, -2);
$this->_orderByString = $orderBy;
@ -533,7 +610,10 @@ class Query extends Object
if($table->isJoinTable() || is_a($table, 'Subquery'))
{
$args = $table->getArguments();
if($args) $this->arguments = array_merge($this->arguments, $args);
if($args)
{
$this->arguments = array_merge($this->arguments, $args);
}
}
}
}
@ -547,30 +627,43 @@ class Query extends Object
if($column->show())
{
$args = $column->getArguments();
if($args) $this->arguments = array_merge($this->arguments, $args);
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);
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);
if(count($args) > 0)
{
$this->arguments = array_merge($this->arguments, $args);
}
}
}
}
return $this->arguments;
}
}
}
/* End of file Query.class.php */
/* Location: ./classes/db/queryparts/Query.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts
@ -6,11 +7,13 @@
*/
class Subquery extends Query
{
/**
* table alias
* @var string
*/
var $alias;
/**
* join type
* @var string
@ -52,7 +55,10 @@ class Subquery extends Query
function isJoinTable()
{
if($this->join_type) return true;
if($this->join_type)
{
return true;
}
return false;
}
@ -60,14 +66,14 @@ class Subquery extends Query
{
$oDB = &DB::getInstance();
return '(' .$oDB->getSelectSql($this, $with_values) . ')';
return '(' . $oDB->getSelectSql($this, $with_values) . ')';
}
function isSubquery()
{
return true;
}
}
/* End of file Subquery.class.php */
/* Location: ./classes/db/queryparts/Subquery.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
@ -6,12 +7,14 @@
*/
class Condition
{
/**
* column name
* @var string
*/
var $column_name;
var $argument;
/**
* operation can use 'equal', 'more', 'excess', 'less', 'below', 'like_tail', 'like_prefix', 'like', 'notlike_tail',
* 'notlike_prefix', 'notlike', 'in', 'notin', 'not_in', 'and', 'or', 'xor', 'not', 'notequal', 'between'
@ -19,14 +22,13 @@ class Condition
* @var string
*/
var $operation;
/**
* pipe can use 'and', 'or'...
* @var string
*/
var $pipe;
var $_value;
var $_show;
var $_value_to_string;
@ -58,13 +60,13 @@ class Condition
*/
function toString($withValue = true)
{
if (!isset($this->_value_to_string))
if(!isset($this->_value_to_string))
{
if (!$this->show())
if(!$this->show())
{
$this->_value_to_string = '';
}
else if ($withValue)
else if($withValue)
{
$this->_value_to_string = $this->toStringWithValue();
}
@ -135,17 +137,34 @@ class Condition
case 'not':
case 'notequal' :
// if variable is not set or is not string or number, return
if(!isset($this->_value)) { $this->_show = false; break;}
if($this->_value === '') { $this->_show = false; break; }
$tmpArray = array('string'=>1, 'integer'=>1);
if(!isset($this->_value))
{
$this->_show = false;
break;
}
if($this->_value === '')
{
$this->_show = false;
break;
}
$tmpArray = array('string' => 1, 'integer' => 1);
if(!isset($tmpArray[gettype($this->_value)]))
{
$this->_show = false; break;
$this->_show = false;
break;
}
break;
case 'between' :
if(!is_array($this->_value)) { $this->_show = false; break;}
if(count($this->_value)!=2) {$this->_show = false; break;}
if(!is_array($this->_value))
{
$this->_show = false;
break;
}
if(count($this->_value) != 2)
{
$this->_show = false;
break;
}
case 'null':
case 'notnull':
break;
@ -171,67 +190,68 @@ class Condition
switch($operation)
{
case 'equal' :
return $name.' = '.$value;
return $name . ' = ' . $value;
break;
case 'more' :
return $name.' >= '.$value;
return $name . ' >= ' . $value;
break;
case 'excess' :
return $name.' > '.$value;
return $name . ' > ' . $value;
break;
case 'less' :
return $name.' <= '.$value;
return $name . ' <= ' . $value;
break;
case 'below' :
return $name.' < '.$value;
return $name . ' < ' . $value;
break;
case 'like_tail' :
case 'like_prefix' :
case 'like' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1')
return $name.' rlike '.$value;
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1')
return $name . ' rlike ' . $value;
else
return $name.' like '.$value;
return $name . ' like ' . $value;
break;
case 'notlike_tail' :
case 'notlike_prefix' :
case 'notlike' :
return $name.' not like '.$value;
return $name . ' not like ' . $value;
break;
case 'in' :
return $name.' in '.$value;
return $name . ' in ' . $value;
break;
case 'notin' :
case 'not_in' :
return $name.' not in '.$value;
return $name . ' not in ' . $value;
break;
case 'notequal' :
return $name.' <> '.$value;
return $name . ' <> ' . $value;
break;
case 'notnull' :
return $name.' is not null';
return $name . ' is not null';
break;
case 'null' :
return $name.' is null';
return $name . ' is null';
break;
case 'and' :
return $name.' & '.$value;
return $name . ' & ' . $value;
break;
case 'or' :
return $name.' | '.$value;
return $name . ' | ' . $value;
break;
case 'xor' :
return $name.' ^ '.$value;
return $name . ' ^ ' . $value;
break;
case 'not' :
return $name.' ~ '.$value;
return $name . ' ~ ' . $value;
break;
case 'between' :
return $name.' between ' . $value[0] . ' and ' . $value[1];
return $name . ' between ' . $value[0] . ' and ' . $value[1];
break;
}
}
}
/* End of file Condition.class.php */
/* Location: ./classes/db/queryparts/condition/Condition.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
@ -6,17 +7,18 @@
*/
class ConditionGroup
{
/**
* condition list
* @var array
*/
var $conditions;
/**
* pipe can use 'and', 'or'...
* @var string
*/
var $pipe;
var $_group;
var $_show;
@ -32,10 +34,18 @@ class ConditionGroup
foreach($conditions as $condition)
{
if($condition->show())
{
$this->conditions[] = $condition;
}
}
if(count($this->conditions) === 0)
{
$this->_show = false;
}
else
{
$this->_show = true;
}
if(count($this->conditions) === 0) $this->_show = false;
else $this->_show = true;
$this->pipe = $pipe;
}
@ -47,7 +57,10 @@ class ConditionGroup
function setPipe($pipe)
{
if($this->pipe !== $pipe) $this->_group = null;
if($this->pipe !== $pipe)
{
$this->_group = null;
}
$this->pipe = $pipe;
}
@ -65,7 +78,10 @@ class ConditionGroup
foreach($this->conditions as $condition)
{
if($cond_indx === 0) $condition->setPipe("");
if($cond_indx === 0)
{
$condition->setPipe("");
}
$group .= $condition->toString($with_value) . ' ';
$cond_indx++;
}
@ -90,10 +106,14 @@ class ConditionGroup
foreach($this->conditions as $condition)
{
$arg = $condition->getArgument();
if($arg) $args[] = $arg;
if($arg)
{
$args[] = $arg;
}
}
return $args;
}
}
/* End of file ConditionGroup.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionGroup.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
@ -6,6 +7,7 @@
*/
class ConditionSubquery extends Condition
{
/**
* constructor
* @param string $column_name
@ -19,6 +21,7 @@ class ConditionSubquery extends Condition
parent::Condition($column_name, $argument, $operation, $pipe);
$this->_value = $this->argument->toString();
}
}
/* End of file ConditionSubquery.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionSubquery.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
@ -6,6 +7,7 @@
*/
class ConditionWithArgument extends Condition
{
/**
* constructor
* @param string $column_name
@ -16,14 +18,19 @@ class ConditionWithArgument extends Condition
*/
function ConditionWithArgument($column_name, $argument, $operation, $pipe = "")
{
if($argument === null) { $this->_show = false; return; }
if($argument === null)
{
$this->_show = false;
return;
}
parent::Condition($column_name, $argument, $operation, $pipe);
$this->_value = $argument->getValue();
}
function getArgument()
{
if(!$this->show()) return;
if(!$this->show())
return;
return $this->argument;
}
@ -38,11 +45,17 @@ class ConditionWithArgument extends Condition
if(is_array($value))
{
$q = '';
foreach ($value as $v) $q .= '?,';
if($q !== '') $q = substr($q, 0, -1);
foreach($value as $v)
{
$q .= '?,';
}
if($q !== '')
{
$q = substr($q, 0, -1);
}
$q = '(' . $q . ')';
}
else
else
{
// Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
if($this->argument->isColumnName())
@ -64,8 +77,14 @@ class ConditionWithArgument extends Condition
{
if(!isset($this->_show))
{
if(!$this->argument->isValid()) $this->_show = false;
if($this->_value === '\'\'') $this->_show = false;
if(!$this->argument->isValid())
{
$this->_show = false;
}
if($this->_value === '\'\'')
{
$this->_show = false;
}
if(!isset($this->_show))
{
return parent::show();
@ -73,6 +92,7 @@ class ConditionWithArgument extends Condition
}
return $this->_show;
}
}
/* End of file ConditionWithArgument.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionWithArgument.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
@ -6,6 +7,7 @@
*/
class ConditionWithoutArgument extends Condition
{
/**
* constructor
* @param string $column_name
@ -17,16 +19,21 @@ class ConditionWithoutArgument extends Condition
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "")
{
parent::Condition($column_name, $argument, $operation, $pipe);
$tmpArray = array('in'=>1, 'notin'=>1, 'not_in'=>1);
$tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
if(isset($tmpArray[$operation]))
{
if(is_array($argument)) $argument = implode($argument, ',');
$this->_value = '('. $argument .')';
if(is_array($argument))
{
$argument = implode($argument, ',');
}
$this->_value = '(' . $argument . ')';
}
else
{
$this->_value = $argument;
}
}
}
}
/* End of file ConditionWithoutArgument.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionWithoutArgument.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* ClickCountExpression
* @author Arnia Software
@ -7,6 +8,7 @@
*/
class ClickCountExpression extends SelectExpression
{
/**
* click count
* @var bool
@ -53,7 +55,7 @@ class ClickCountExpression extends SelectExpression
return "$this->column_name";
}
}
}
}
/* End of file ClickCountExpression.class.php */
/* Location: ./classes/db/queryparts/expression/ClickCountExpression.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* DeleteExpression
*
@ -9,6 +10,7 @@
*/
class DeleteExpression extends Expression
{
/**
* column value
* @var mixed
@ -39,15 +41,22 @@ class DeleteExpression extends Expression
function getValue()
{
// TODO Escape value according to column type instead of variable type
if(!is_numeric($this->value)) return "'".$this->value."'";
if(!is_numeric($this->value))
{
return "'" . $this->value . "'";
}
return $this->value;
}
function show()
{
if(!$this->value) return false;
if(!$this->value)
{
return false;
}
return true;
}
}
/* End of file DeleteExpression.class.php */
/* Location: ./classes/db/queryparts/expression/DeleteExpression.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* Expression
* Represents an expression used in select/update/insert/delete statements
@ -13,6 +14,7 @@
*/
class Expression
{
/**
* column name
* @var string
@ -45,8 +47,9 @@ class Expression
*/
function getExpression()
{
}
}
}
/* End of file Expression.class.php */
/* Location: ./classes/db/queryparts/expression/Expression.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* InsertExpression
*
@ -8,6 +9,7 @@
*/
class InsertExpression extends Expression
{
/**
* argument
* @var object
@ -29,15 +31,23 @@ class InsertExpression extends Expression
function getValue($with_values = true)
{
if($with_values)
{
return $this->argument->getValue();
}
return '?';
}
function show()
{
if(!$this->argument) return false;
if(!$this->argument)
{
return false;
}
$value = $this->argument->getValue();
if(!isset($value)) return false;
if(!isset($value))
{
return false;
}
return true;
}
@ -48,11 +58,16 @@ class InsertExpression extends Expression
function getArguments()
{
if ($this->argument)
if($this->argument)
{
return array($this->argument);
}
else
{
return array();
}
}
}
/* End of file InsertExpression.class.php */
/* Location: ./classes/db/queryparts/expression/InsertExpression.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* SelectExpression
* Represents an expresion that appears in the select clause
@ -6,8 +7,8 @@
* $column_name can be:
* - a table column name
* - an sql function - like count(*)
* - an sql expression - substr(column_name, 1, 8) or score1 + score2
* $column_name is already escaped
* - an sql expression - substr(column_name, 1, 8) or score1 + score2
* $column_name is already escaped
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
@ -15,6 +16,7 @@
*/
class SelectExpression extends Expression
{
/**
* column alias name
* @var string
@ -39,7 +41,7 @@ class SelectExpression extends Expression
*/
function getExpression()
{
return sprintf("%s%s", $this->column_name, $this->column_alias ? " as ".$this->column_alias : "");
return sprintf("%s%s", $this->column_name, $this->column_alias ? " as " . $this->column_alias : "");
}
function show()
@ -61,6 +63,7 @@ class SelectExpression extends Expression
{
return false;
}
}
/* End of file SelectExpression.class.php */
/* Location: ./classes/db/queryparts/expression/SelectExpression.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* StarExpression
* Represents the * in 'select * from ...' statements
@ -9,6 +10,7 @@
*/
class StarExpression extends SelectExpression
{
/**
* constructor, set the column to asterisk
* @return void
@ -28,6 +30,7 @@ class StarExpression extends SelectExpression
// StarExpression has no arguments
return array();
}
}
/* End of file StarExpression.class.php */
/* Location: ./classes/db/queryparts/expression/StarExpression.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* UpdateExpression
*
@ -8,6 +9,7 @@
*/
class UpdateExpression extends Expression
{
/**
* argument
* @var object
@ -33,7 +35,9 @@ class UpdateExpression extends Expression
function getExpression($with_value = true)
{
if($with_value)
{
return $this->getExpressionWithValue();
}
return $this->getExpressionWithoutValue();
}
@ -46,7 +50,9 @@ class UpdateExpression extends Expression
$value = $this->argument->getValue();
$operation = $this->argument->getColumnOperation();
if(isset($operation))
{
return "$this->column_name = $this->column_name $operation $value";
}
return "$this->column_name = $value";
}
@ -59,7 +65,9 @@ class UpdateExpression extends Expression
{
$operation = $this->argument->getColumnOperation();
if(isset($operation))
{
return "$this->column_name = $this->column_name $operation ?";
}
return "$this->column_name = ?";
}
@ -67,15 +75,24 @@ class UpdateExpression extends Expression
{
// TODO Escape value according to column type instead of variable type
$value = $this->argument->getValue();
if(!is_numeric($value)) return "'".$value."'";
if(!is_numeric($value))
{
return "'" . $value . "'";
}
return $value;
}
function show()
{
if(!$this->argument) return false;
if(!$this->argument)
{
return false;
}
$value = $this->argument->getValue();
if(!isset($value)) return false;
if(!isset($value))
{
return false;
}
return true;
}
@ -86,12 +103,16 @@ class UpdateExpression extends Expression
function getArguments()
{
if ($this->argument)
if($this->argument)
{
return array($this->argument);
}
else
{
return array();
}
}
}
}
/* End of file UpdateExpression.class.php */
/* Location: ./classes/db/queryparts/expression/UpdateExpression.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* UpdateExpression
*
@ -8,6 +9,7 @@
*/
class UpdateExpressionWithoutArgument extends UpdateExpression
{
/**
* argument
* @var object
@ -35,15 +37,24 @@ class UpdateExpressionWithoutArgument extends UpdateExpression
{
// TODO Escape value according to column type instead of variable type
$value = $this->argument;
if(!is_numeric($value)) return "'".$value."'";
if(!is_numeric($value))
{
return "'" . $value . "'";
}
return $value;
}
function show()
{
if(!$this->argument) return false;
if(!$this->argument)
{
return false;
}
$value = $this->argument;
if(!isset($value)) return false;
if(!isset($value))
{
return false;
}
return true;
}
@ -56,6 +67,7 @@ class UpdateExpressionWithoutArgument extends UpdateExpression
{
return array();
}
}
/* End of file UpdateExpressionWithoutArgument.class.php */
/* Location: ./classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/limit
@ -6,21 +7,25 @@
*/
class Limit
{
/**
* start number
* @var int
*/
var $start;
/**
* list count
* @var int
*/
var $list_count;
/**
* page count
* @var int
*/
var $page_count;
/**
* current page
* @var int
@ -34,10 +39,10 @@ class Limit
* @param int $page_count
* @return void
*/
function Limit($list_count, $page= NULL, $page_count= NULL)
function Limit($list_count, $page = NULL, $page_count = NULL)
{
$this->list_count = $list_count;
if ($page)
if($page)
{
$list_count_value = $list_count->getValue();
$page_value = $page->getValue();
@ -53,8 +58,14 @@ class Limit
*/
function isPageHandler()
{
if ($this->page)return true;
else return false;
if($this->page)
{
return true;
}
else
{
return false;
}
}
function getOffset()
@ -69,9 +80,16 @@ class Limit
function toString()
{
if ($this->page) return $this->start . ' , ' . $this->list_count->getValue();
else return $this->list_count->getValue();
if($this->page)
{
return $this->start . ' , ' . $this->list_count->getValue();
}
else
{
return $this->list_count->getValue();
}
}
}
/* End of file Limit.class.php */
/* Location: ./classes/db/limit/Limit.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/order
@ -6,11 +7,13 @@
*/
class OrderByColumn
{
/**
* column name
* @var string
*/
var $column_name;
/**
* sort order
* @var string
@ -46,10 +49,15 @@ class OrderByColumn
{
$args = array();
if(is_a($this->column_name, 'Argument'))
$args[]= $this->column_name;
{
$args[] = $this->column_name;
}
if(is_a($this->sort_order, 'Argument'))
$args[] = $this->sort_order;
{
$args[] = $this->sort_order;
}
}
}
/* End of file OrderByColumn.class.php */
/* Location: ./classes/db/order/OrderByColumn.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
@ -6,16 +7,19 @@
*/
class CubridTableWithHint extends Table
{
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* index hint list
* @var array
@ -53,14 +57,15 @@ class CubridTableWithHint extends Table
if($index_hint_type !== 'IGNORE')
{
$result .= $this->alias . '.'
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
. ($index_hint_type == 'FORCE' ? '(+)' : '')
. ', ';
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
. ($index_hint_type == 'FORCE' ? '(+)' : '')
. ', ';
}
}
$result = substr($result, 0, -2);
return $result;
}
}
/* End of file CubridTableWithHint.class.php */
/* Location: ./classes/db/queryparts/table/CubridTableWithHint.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
@ -6,11 +7,13 @@
*/
class IndexHint
{
/**
* index name
* @var string
*/
var $index_name;
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var string
@ -38,6 +41,7 @@ class IndexHint
{
return $this->index_hint_type;
}
}
/* End of file IndexHint.class.php */
/* Location: ./classes/db/queryparts/table/IndexHint.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* class JoinTable
* $conditions in an array of Condition objects
@ -9,11 +10,13 @@
*/
class JoinTable extends Table
{
/**
* join type
* @var string
*/
var $join_type;
/**
* condition list
* @var array
@ -37,11 +40,13 @@ class JoinTable extends Table
function toString($with_value = true)
{
$part = $this->join_type . ' ' . $this->name ;
$part = $this->join_type . ' ' . $this->name;
$part .= $this->alias ? ' as ' . $this->alias : '';
$part .= ' on ';
foreach($this->conditions as $conditionGroup)
{
$part .= $conditionGroup->toString($with_value);
}
return $part;
}
@ -54,9 +59,12 @@ class JoinTable extends Table
{
$args = array();
foreach($this->conditions as $conditionGroup)
$args = array_merge($args, $conditionGroup->getArguments());
{
$args = array_merge($args, $conditionGroup->getArguments());
}
return $args;
}
}
/* End of file JoinTable.class.php */
/* Location: ./classes/db/queryparts/table/JoinTable.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
@ -6,16 +7,19 @@
*/
class MssqlTableWithHint extends Table
{
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var array
@ -40,12 +44,14 @@ class MssqlTableWithHint extends Table
$result = parent::toString();
$index_hint_string = '';
$indexTypeList = array('USE'=>1, 'FORCE'=>1);
$indexTypeList = array('USE' => 1, 'FORCE' => 1);
foreach($this->index_hints_list as $index_hint)
{
$index_hint_type = $index_hint->getIndexHintType();
if(isset($indexTypeList[$index_hint_type]))
{
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
}
}
if($index_hint_string != '')
{
@ -53,6 +59,7 @@ class MssqlTableWithHint extends Table
}
return $result;
}
}
/* End of file MssqlTableWithHint.class.php */
/* Location: ./classes/db/queryparts/table/MssqlTableWithHint.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
@ -6,16 +7,19 @@
*/
class MysqlTableWithHint extends Table
{
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var array
@ -39,13 +43,24 @@ class MysqlTableWithHint extends Table
{
$result = parent::toString();
$use_index_hint = ''; $force_index_hint = ''; $ignore_index_hint = '';
$use_index_hint = '';
$force_index_hint = '';
$ignore_index_hint = '';
foreach($this->index_hints_list as $index_hint)
{
$index_hint_type = $index_hint->getIndexHintType();
if($index_hint_type == 'USE') $use_index_hint .= $index_hint->getIndexName() . ', ';
else if($index_hint_type == 'FORCE') $force_index_hint .= $index_hint->getIndexName() . ', ';
else if($index_hint_type == 'IGNORE') $ignore_index_hint .= $index_hint->getIndexName() . ', ';
if($index_hint_type == 'USE')
{
$use_index_hint .= $index_hint->getIndexName() . ', ';
}
else if($index_hint_type == 'FORCE')
{
$force_index_hint .= $index_hint->getIndexName() . ', ';
}
else if($index_hint_type == 'IGNORE')
{
$ignore_index_hint .= $index_hint->getIndexName() . ', ';
}
}
if($use_index_hint != '')
{
@ -61,6 +76,7 @@ class MysqlTableWithHint extends Table
}
return $result;
}
}
/* End of file MysqlTableWithHint.class.php */
/* Location: ./classes/db/queryparts/table/MysqlTableWithHint.class.php */

View file

@ -1,4 +1,5 @@
<?php
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
@ -6,11 +7,13 @@
*/
class Table
{
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
@ -49,7 +52,7 @@ class Table
{
return false;
}
}
}
/* End of file Table.class.php */
/* Location: ./classes/db/queryparts/table/Table.class.php */