mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 01:23:32 +09:00
adds comments for phpDoc
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10739 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
94be154d88
commit
c65e9d3071
29 changed files with 1701 additions and 583 deletions
|
|
@ -1,23 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts
|
||||
* @version 0.1
|
||||
*/
|
||||
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
|
||||
*/
|
||||
var $priority;
|
||||
|
||||
/**
|
||||
* column list
|
||||
* @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
|
||||
*/
|
||||
var $limit;
|
||||
|
||||
/**
|
||||
* argument list
|
||||
* @var array
|
||||
*/
|
||||
var $arguments = null;
|
||||
|
||||
/**
|
||||
* column list
|
||||
* @var array
|
||||
*/
|
||||
var $columnList = null;
|
||||
|
||||
/**
|
||||
* order by text
|
||||
* @var string
|
||||
*/
|
||||
var $_orderByString;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $queryID
|
||||
* @param string $action
|
||||
* @param string|array $columns
|
||||
* @param string|array $tables
|
||||
* @param string|array $conditions
|
||||
* @param string|array $groups
|
||||
* @param string|array $orderby
|
||||
* @param int $limit
|
||||
* @param string $priority
|
||||
* @return void
|
||||
*/
|
||||
function Query($queryID = null
|
||||
, $action = null
|
||||
, $columns = null
|
||||
|
|
@ -128,32 +193,62 @@
|
|||
}
|
||||
|
||||
// START Fluent interface
|
||||
/**
|
||||
* seleect set
|
||||
* @param string|array $columns
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function select($columns= null){
|
||||
$this->action = 'select';
|
||||
$this->setColumns($columns);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* from set
|
||||
* @param string|array $tables
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function from($tables){
|
||||
$this->setTables($tables);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* where set
|
||||
* @param string|array $conditions
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function where($conditions){
|
||||
$this->setConditions($conditions);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* groupBy set
|
||||
* @param string|array $groups
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function groupBy($groups){
|
||||
$this->setGroups($groups);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* orderBy set
|
||||
* @param string|array $order
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function orderBy($order){
|
||||
$this->setOrder($order);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* limit set
|
||||
* @param int $limit
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function limit($limit){
|
||||
$this->setLimit($limit);
|
||||
return $this;
|
||||
|
|
@ -168,6 +263,11 @@
|
|||
return $this->priority?'LOW_PRIORITY':'';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return select sql
|
||||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getSelectString($with_values = true){
|
||||
foreach($this->columns as $column){
|
||||
if($column->show())
|
||||
|
|
@ -180,6 +280,11 @@
|
|||
return trim(implode($select, ', '));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return update sql
|
||||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getUpdateString($with_values = true){
|
||||
foreach($this->columns as $column){
|
||||
if($column->show())
|
||||
|
|
@ -188,6 +293,11 @@
|
|||
return trim(implode($update, ', '));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return insert sql
|
||||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getInsertString($with_values = true){
|
||||
$columnsList = '';
|
||||
if($this->subquery){ // means we have insert-select
|
||||
|
|
@ -221,10 +331,14 @@
|
|||
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
|
||||
/**
|
||||
* 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
|
||||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getFromString($with_values = true){
|
||||
$from = '';
|
||||
$simple_table_count = 0;
|
||||
|
|
@ -240,6 +354,12 @@
|
|||
return $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return where sql
|
||||
* @param boolean $with_values
|
||||
* @param boolean $with_optimization
|
||||
* @return string
|
||||
*/
|
||||
function getWhereString($with_values = true, $with_optimization = true){
|
||||
$where = '';
|
||||
$condition_count = 0;
|
||||
|
|
@ -274,6 +394,10 @@
|
|||
return trim($where);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return groupby sql
|
||||
* @return string
|
||||
*/
|
||||
function getGroupByString(){
|
||||
$groupBy = '';
|
||||
if($this->groups) if($this->groups[0] !== "")
|
||||
|
|
@ -281,6 +405,10 @@
|
|||
return $groupBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return orderby sql
|
||||
* @return string
|
||||
*/
|
||||
function getOrderByString(){
|
||||
if(!$this->_orderByString){
|
||||
if(count($this->orderby) === 0) return '';
|
||||
|
|
@ -298,6 +426,10 @@
|
|||
return $this->limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return limit sql
|
||||
* @return string
|
||||
*/
|
||||
function getLimitString(){
|
||||
$limit = '';
|
||||
if(count($this->limit) > 0){
|
||||
|
|
@ -311,6 +443,10 @@
|
|||
return $this->tables[0]->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return argument list
|
||||
* @return array
|
||||
*/
|
||||
function getArguments(){
|
||||
if(!isset($this->arguments)){
|
||||
$this->arguments = array();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts
|
||||
* @version 0.1
|
||||
*/
|
||||
class Subquery extends Query {
|
||||
/**
|
||||
* table alias
|
||||
* @var string
|
||||
*/
|
||||
var $alias;
|
||||
/**
|
||||
* join type
|
||||
* @var string
|
||||
*/
|
||||
var $join_type;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $alias
|
||||
* @param string|array $columns
|
||||
* @param string|array $tables
|
||||
* @param string|array $conditions
|
||||
* @param string|array $groups
|
||||
* @param string|array $orderby
|
||||
* @param int $limit
|
||||
* @param string $join_type
|
||||
* @return void
|
||||
*/
|
||||
function Subquery($alias, $columns, $tables, $conditions, $groups, $orderby, $limit, $join_type = null){
|
||||
$this->alias = $alias;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,26 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
* @version 0.1
|
||||
*/
|
||||
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', 'and', 'or', 'xor', 'not', 'notequal', 'between'
|
||||
* @var string
|
||||
*/
|
||||
var $operation;
|
||||
/**
|
||||
* pipe can use 'and', 'or'...
|
||||
* @var string
|
||||
*/
|
||||
var $pipe;
|
||||
|
||||
var $_value;
|
||||
|
|
@ -11,6 +28,14 @@
|
|||
var $_show;
|
||||
var $_value_to_string;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param mixed $argument
|
||||
* @param string $operation
|
||||
* @param string $pipe
|
||||
* @return void
|
||||
*/
|
||||
function Condition($column_name, $argument, $operation, $pipe){
|
||||
$this->column_name = $column_name;
|
||||
$this->argument = $argument;
|
||||
|
|
@ -23,6 +48,11 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* value to string
|
||||
* @param boolean $withValue
|
||||
* @return string
|
||||
*/
|
||||
function toString($withValue = true){
|
||||
if (!isset($this->_value_to_string)) {
|
||||
if (!$this->show())
|
||||
|
|
@ -41,10 +71,18 @@
|
|||
return $this->_value_to_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* change string without value
|
||||
* @return string
|
||||
*/
|
||||
function toStringWithoutValue(){
|
||||
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* change string with value
|
||||
* @return string
|
||||
*/
|
||||
function toStringWithValue(){
|
||||
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
|
||||
}
|
||||
|
|
@ -53,6 +91,9 @@
|
|||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
function show(){
|
||||
if(!isset($this->_show)){
|
||||
if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') {
|
||||
|
|
@ -93,6 +134,11 @@
|
|||
return $this->_show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return condition string
|
||||
* @param int|string|array $value
|
||||
* @return string
|
||||
*/
|
||||
function getConditionPart($value) {
|
||||
$name = $this->column_name;
|
||||
$operation = $this->operation;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
* @version 0.1
|
||||
*/
|
||||
class ConditionGroup {
|
||||
/**
|
||||
* condition list
|
||||
* @var array
|
||||
*/
|
||||
var $conditions;
|
||||
/**
|
||||
* pipe can use 'and', 'or'...
|
||||
* @var string
|
||||
*/
|
||||
var $pipe;
|
||||
|
||||
var $_group;
|
||||
var $_show;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param array $conditions
|
||||
* @param string $pipe
|
||||
* @return void
|
||||
*/
|
||||
function ConditionGroup($conditions, $pipe = "") {
|
||||
$this->conditions = array();
|
||||
foreach($conditions as $condition){
|
||||
|
|
@ -28,6 +46,11 @@
|
|||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* value to string
|
||||
* @param boolean $with_value
|
||||
* @return string
|
||||
*/
|
||||
function toString($with_value = true){
|
||||
if(!isset($this->_group)){
|
||||
$cond_indx = 0;
|
||||
|
|
@ -48,6 +71,10 @@
|
|||
return $this->_group;
|
||||
}
|
||||
|
||||
/**
|
||||
* return argument list
|
||||
* @return array
|
||||
*/
|
||||
function getArguments(){
|
||||
$args = array();
|
||||
foreach($this->conditions as $condition){
|
||||
|
|
@ -57,4 +84,4 @@
|
|||
return $args;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
* @version 0.1
|
||||
*/
|
||||
class ConditionSubquery extends Condition {
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param mixed $argument
|
||||
* @param string $operation
|
||||
* @param string $pipe
|
||||
* @return void
|
||||
*/
|
||||
function ConditionSubquery($column_name, $argument, $operation, $pipe = ""){
|
||||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
$this->_value = $this->argument->toString();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
* @version 0.1
|
||||
*/
|
||||
class ConditionWithArgument extends Condition {
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param mixed $argument
|
||||
* @param string $operation
|
||||
* @param string $pipe
|
||||
* @return void
|
||||
*/
|
||||
function ConditionWithArgument($column_name, $argument, $operation, $pipe = ""){
|
||||
if($argument === null) { $this->_show = false; return; }
|
||||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
|
|
@ -13,6 +25,10 @@
|
|||
return $this->argument;
|
||||
}
|
||||
|
||||
/**
|
||||
* change string without value
|
||||
* @return string
|
||||
*/
|
||||
function toStringWithoutValue(){
|
||||
$value = $this->argument->getUnescapedValue();
|
||||
|
||||
|
|
@ -37,6 +53,9 @@
|
|||
return $this->pipe . ' ' . $this->getConditionPart($q);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
function show(){
|
||||
if(!isset($this->_show)){
|
||||
if(!$this->argument->isValid()) $this->_show = false;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
* @version 0.1
|
||||
*/
|
||||
class ConditionWithoutArgument extends Condition {
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param mixed $argument
|
||||
* @param string $operation
|
||||
* @param string $pipe
|
||||
* @return void
|
||||
*/
|
||||
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = ""){
|
||||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
if(in_array($operation, array('in', 'notin'))){
|
||||
|
|
|
|||
|
|
@ -1,15 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class ClickCountExpression
|
||||
* ClickCountExpression
|
||||
* @author Arnia Software
|
||||
* @brief
|
||||
*
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class ClickCountExpression extends SelectExpression {
|
||||
/**
|
||||
* click count
|
||||
* @var boolean
|
||||
*/
|
||||
var $click_count;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param string $alias
|
||||
* @param boolean $click_count
|
||||
* @return void
|
||||
*/
|
||||
function ClickCountExpression($column_name, $alias = NULL, $click_count = false){
|
||||
parent::SelectExpression($column_name, $alias);
|
||||
|
||||
|
|
@ -25,9 +34,13 @@
|
|||
return $this->click_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column = column + 1
|
||||
* @return string
|
||||
*/
|
||||
function getExpression(){
|
||||
return "$this->column_name = $this->column_name + 1";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,20 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* @class DeleteExpression
|
||||
* @author Arnia Software
|
||||
* @brief
|
||||
* DeleteExpression
|
||||
*
|
||||
* @author Arnia Software
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
* @todo Fix this class
|
||||
*/
|
||||
|
||||
// TODO Fix this class
|
||||
class DeleteExpression extends Expression {
|
||||
/**
|
||||
* column value
|
||||
* @var mixed
|
||||
*/
|
||||
var $value;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
function DeleteExpression($column_name, $value){
|
||||
parent::Expression($column_name);
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column = value
|
||||
* @return string
|
||||
*/
|
||||
function getExpression(){
|
||||
return "$this->column_name = $this->value";
|
||||
}
|
||||
|
|
@ -32,4 +47,4 @@
|
|||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* @class Expression
|
||||
* @author Corina
|
||||
* @brief Represents an expression used in select/update/insert/delete statements
|
||||
* Expression
|
||||
* Represents an expression used in select/update/insert/delete statements
|
||||
*
|
||||
* Examples (expressions are inside double square brackets):
|
||||
* select [[columnA]], [[columnB as aliasB]] from tableA
|
||||
* update tableA set [[columnA = valueA]] where columnB = something
|
||||
*
|
||||
* @author Corina
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class Expression {
|
||||
/**
|
||||
* column name
|
||||
* @var string
|
||||
*/
|
||||
var $column_name;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @return void
|
||||
*/
|
||||
function Expression($column_name){
|
||||
$this->column_name = $column_name;
|
||||
}
|
||||
|
|
@ -25,6 +35,10 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column as alias
|
||||
* @return string
|
||||
*/
|
||||
function getExpression() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class InsertExpression
|
||||
* @author Arnia Software
|
||||
* @brief
|
||||
* InsertExpression
|
||||
*
|
||||
* @author Arnia Software
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class InsertExpression extends Expression {
|
||||
/**
|
||||
* argument
|
||||
* @var object
|
||||
*/
|
||||
var $argument;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param object $argument
|
||||
* @return void
|
||||
*/
|
||||
function InsertExpression($column_name, $argument){
|
||||
parent::Expression($column_name);
|
||||
$this->argument = $argument;
|
||||
|
|
|
|||
|
|
@ -1,26 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class SelectExpression
|
||||
* @author Arnia Software
|
||||
* @brief Represents an expresion that appears in the select clause
|
||||
* SelectExpression
|
||||
* Represents an expresion that appears in the select clause
|
||||
*
|
||||
* @remarks
|
||||
* $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
|
||||
*
|
||||
* @author Arnia Software
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class SelectExpression extends Expression {
|
||||
/**
|
||||
* column alias name
|
||||
* @var string
|
||||
*/
|
||||
var $column_alias;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*/
|
||||
function SelectExpression($column_name, $alias = NULL){
|
||||
parent::Expression($column_name);
|
||||
$this->column_alias = $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column as alias
|
||||
* @return string
|
||||
*/
|
||||
function getExpression() {
|
||||
return sprintf("%s%s", $this->column_name, $this->column_alias ? " as ".$this->column_alias : "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class StarExpression
|
||||
* @author Corina
|
||||
* @brief Represents the * in 'select * from ...' statements
|
||||
* StarExpression
|
||||
* Represents the * in 'select * from ...' statements
|
||||
*
|
||||
* @author Corina
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class StarExpression extends SelectExpression {
|
||||
|
||||
/**
|
||||
* constructor, set the column to asterisk
|
||||
* @return void
|
||||
*/
|
||||
function StarExpression(){
|
||||
parent::SelectExpression("*");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* @class UpdateExpression
|
||||
* @author Arnia Software
|
||||
* @brief
|
||||
* UpdateExpression
|
||||
*
|
||||
* @author Arnia Software
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class UpdateExpression extends Expression {
|
||||
/**
|
||||
* argument
|
||||
* @var object
|
||||
*/
|
||||
var $argument;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param object $argument
|
||||
* @return void
|
||||
*/
|
||||
function UpdateExpression($column_name, $argument){
|
||||
parent::Expression($column_name);
|
||||
$this->argument = $argument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column = value
|
||||
* @return string
|
||||
*/
|
||||
function getExpression($with_value = true){
|
||||
if($with_value)
|
||||
return $this->getExpressionWithValue();
|
||||
return $this->getExpressionWithoutValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column = value
|
||||
* @return string
|
||||
*/
|
||||
function getExpressionWithValue(){
|
||||
$value = $this->argument->getValue();
|
||||
$operation = $this->argument->getColumnOperation();
|
||||
|
|
@ -28,6 +46,11 @@
|
|||
return "$this->column_name = $value";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column expression, ex) column = ?
|
||||
* Can use prepare statement
|
||||
* @return string
|
||||
*/
|
||||
function getExpressionWithoutValue(){
|
||||
$operation = $this->argument->getColumnOperation();
|
||||
if(isset($operation))
|
||||
|
|
|
|||
|
|
@ -1,14 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* @class UpdateExpression
|
||||
* @author Arnia Software
|
||||
* @brief
|
||||
* UpdateExpression
|
||||
*
|
||||
* @author Arnia Software
|
||||
* @package /classes/db/queryparts/expression
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class UpdateExpressionWithoutArgument extends UpdateExpression {
|
||||
/**
|
||||
* argument
|
||||
* @var object
|
||||
*/
|
||||
var $argument;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param object $argument
|
||||
* @return void
|
||||
*/
|
||||
function UpdateExpressionWithoutArgument($column_name, $argument){
|
||||
parent::Expression($column_name);
|
||||
$this->argument = $argument;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/limit
|
||||
* @version 0.1
|
||||
*/
|
||||
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
|
||||
*/
|
||||
var $page;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param int $list_count
|
||||
* @param int $page
|
||||
* @param int $page_count
|
||||
* @return void
|
||||
*/
|
||||
function Limit($list_count, $page= NULL, $page_count= NULL){
|
||||
$this->list_count = $list_count;
|
||||
if ($page){
|
||||
|
|
@ -16,7 +44,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
function isPageHandler(){//in case you choose to use query limit in other cases than page select
|
||||
/**
|
||||
* In case you choose to use query limit in other cases than page select
|
||||
* @return boolean
|
||||
*/
|
||||
function isPageHandler(){
|
||||
if ($this->page)return true;
|
||||
else return false;
|
||||
}
|
||||
|
|
@ -34,4 +66,4 @@
|
|||
else return $this->list_count->getValue();
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/order
|
||||
* @version 0.1
|
||||
*/
|
||||
class OrderByColumn {
|
||||
/**
|
||||
* column name
|
||||
* @var string
|
||||
*/
|
||||
var $column_name;
|
||||
/**
|
||||
* sort order
|
||||
* @var string
|
||||
*/
|
||||
var $sort_order;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
* @param string $sort_order
|
||||
* @return void
|
||||
*/
|
||||
function OrderByColumn($column_name, $sort_order){
|
||||
$this->column_name = $column_name;
|
||||
$this->sort_order = $sort_order;
|
||||
|
|
@ -28,4 +47,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/table
|
||||
* @version 0.1
|
||||
*/
|
||||
class CubridTableWithHint extends Table {
|
||||
/**
|
||||
* table name
|
||||
* @var string
|
||||
*/
|
||||
var $name;
|
||||
/**
|
||||
* table alias
|
||||
* @var string
|
||||
*/
|
||||
var $alias;
|
||||
/**
|
||||
* index hint list
|
||||
* @var array
|
||||
*/
|
||||
var $index_hints_list;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param string $alias
|
||||
* @param array $index_hints_list
|
||||
* @return void
|
||||
*/
|
||||
function CubridTableWithHint($name, $alias = NULL, $index_hints_list){
|
||||
parent::Table($name, $alias);
|
||||
$this->index_hints_list = $index_hints_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return index hint string
|
||||
* @return string
|
||||
*/
|
||||
function getIndexHintString(){
|
||||
$result = '';
|
||||
|
||||
|
|
@ -32,4 +59,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/table
|
||||
* @version 0.1
|
||||
*/
|
||||
class IndexHint {
|
||||
/**
|
||||
* index name
|
||||
* @var string
|
||||
*/
|
||||
var $index_name;
|
||||
/**
|
||||
* index hint type, ex) IGNORE, FORCE, USE...
|
||||
* @var string
|
||||
*/
|
||||
var $index_hint_type;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $index_name
|
||||
* @param string $index_hint_type
|
||||
* @return void
|
||||
*/
|
||||
function IndexHint($index_name, $index_hint_type){
|
||||
$this->index_name = $index_name;
|
||||
$this->index_hint_type = $index_hint_type;
|
||||
|
|
@ -18,4 +36,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class JoinTable
|
||||
* @author Arnia Software
|
||||
* @brief
|
||||
*
|
||||
* @remarks
|
||||
* class JoinTable
|
||||
* $conditions in an array of Condition objects
|
||||
*
|
||||
*
|
||||
* @author Arnia Software
|
||||
* @package /classes/db/queryparts/table
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
class JoinTable extends Table {
|
||||
/**
|
||||
* join type
|
||||
* @var string
|
||||
*/
|
||||
var $join_type;
|
||||
/**
|
||||
* condition list
|
||||
* @var array
|
||||
*/
|
||||
var $conditions;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param string $alias
|
||||
* @param string $join_type
|
||||
* @param array $conditions
|
||||
* @return void
|
||||
*/
|
||||
function JoinTable($name, $alias, $join_type, $conditions){
|
||||
parent::Table($name, $alias);
|
||||
$this->join_type = $join_type;
|
||||
|
|
@ -43,4 +56,4 @@
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/table
|
||||
* @version 0.1
|
||||
*/
|
||||
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
|
||||
*/
|
||||
var $index_hints_list;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param string $alias
|
||||
* @param string $index_hints_list
|
||||
* @return void
|
||||
*/
|
||||
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list){
|
||||
parent::Table($name, $alias);
|
||||
$this->index_hints_list = $index_hints_list;
|
||||
|
|
@ -26,4 +49,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/table
|
||||
* @version 0.1
|
||||
*/
|
||||
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
|
||||
*/
|
||||
var $index_hints_list;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param string $alias
|
||||
* @param string $index_hints_list
|
||||
* @return void
|
||||
*/
|
||||
function MysqlTableWithHint($name, $alias = NULL, $index_hints_list){
|
||||
parent::Table($name, $alias);
|
||||
$this->index_hints_list = $index_hints_list;
|
||||
|
|
@ -33,4 +56,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/table
|
||||
* @version 0.1
|
||||
*/
|
||||
class Table {
|
||||
/**
|
||||
* table name
|
||||
* @var string
|
||||
*/
|
||||
var $name;
|
||||
/**
|
||||
* table alias
|
||||
* @var string
|
||||
*/
|
||||
var $alias;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*/
|
||||
function Table($name, $alias = NULL){
|
||||
$this->name = $name;
|
||||
$this->alias = $alias;
|
||||
|
|
@ -27,4 +45,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue