mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 20:12:14 +09:00
issue 2662 db class coding convention
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12216 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
3daadb29dc
commit
d77d426c4f
16 changed files with 863 additions and 772 deletions
|
|
@ -1,11 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ClickCountExpression
|
* ClickCountExpression
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class ClickCountExpression extends SelectExpression {
|
class ClickCountExpression extends SelectExpression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* click count
|
* click count
|
||||||
* @var bool
|
* @var bool
|
||||||
|
|
@ -19,10 +20,12 @@
|
||||||
* @param bool $click_count
|
* @param bool $click_count
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ClickCountExpression($column_name, $alias = NULL, $click_count = false){
|
function ClickCountExpression($column_name, $alias = NULL, $click_count = false)
|
||||||
|
{
|
||||||
parent::SelectExpression($column_name, $alias);
|
parent::SelectExpression($column_name, $alias);
|
||||||
|
|
||||||
if(!is_bool($click_count)){
|
if(!is_bool($click_count))
|
||||||
|
{
|
||||||
error_log("Click_count value for $column_name was not boolean", 0);
|
error_log("Click_count value for $column_name was not boolean", 0);
|
||||||
$this->click_count = false;
|
$this->click_count = false;
|
||||||
return;
|
return;
|
||||||
|
|
@ -30,7 +33,8 @@
|
||||||
$this->click_count = $click_count;
|
$this->click_count = $click_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show()
|
||||||
|
{
|
||||||
return $this->click_count;
|
return $this->click_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,9 +42,11 @@
|
||||||
* Return column expression, ex) column = column + 1
|
* Return column expression, ex) column = column + 1
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpression(){
|
function getExpression()
|
||||||
|
{
|
||||||
return "$this->column_name = $this->column_name + 1";
|
return "$this->column_name = $this->column_name + 1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
/* End of file ClickCountExpression.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/expression/ClickCountExpression.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* DeleteExpression
|
* DeleteExpression
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @todo Fix this class
|
* @todo Fix this class
|
||||||
*/
|
*/
|
||||||
|
class DeleteExpression extends Expression
|
||||||
class DeleteExpression extends Expression {
|
{
|
||||||
/**
|
/**
|
||||||
* column value
|
* column value
|
||||||
* @var mixed
|
* @var mixed
|
||||||
|
|
@ -21,7 +21,8 @@
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function DeleteExpression($column_name, $value){
|
function DeleteExpression($column_name, $value)
|
||||||
|
{
|
||||||
parent::Expression($column_name);
|
parent::Expression($column_name);
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
@ -30,21 +31,23 @@
|
||||||
* Return column expression, ex) column = value
|
* Return column expression, ex) column = value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpression(){
|
function getExpression()
|
||||||
|
{
|
||||||
return "$this->column_name = $this->value";
|
return "$this->column_name = $this->value";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(){
|
function getValue()
|
||||||
|
{
|
||||||
// TODO Escape value according to column type instead of variable type
|
// 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;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(){
|
function show()
|
||||||
|
{
|
||||||
if(!$this->value) return false;
|
if(!$this->value) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file DeleteExpression.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/expression/DeleteExpression.class.php */
|
||||||
?>
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Expression
|
* Expression
|
||||||
* Represents an expression used in select/update/insert/delete statements
|
* Represents an expression used in select/update/insert/delete statements
|
||||||
*
|
*
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class Expression {
|
class Expression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* column name
|
* column name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -23,15 +24,18 @@
|
||||||
* @param string $column_name
|
* @param string $column_name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Expression($column_name){
|
function Expression($column_name)
|
||||||
|
{
|
||||||
$this->column_name = $column_name;
|
$this->column_name = $column_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColumnName(){
|
function getColumnName()
|
||||||
|
{
|
||||||
return $this->column_name;
|
return $this->column_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,6 +43,10 @@
|
||||||
* Return column expression, ex) column as alias
|
* Return column expression, ex) column as alias
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpression() {
|
function getExpression()
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of file Expression.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/expression/Expression.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* InsertExpression
|
* InsertExpression
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class InsertExpression extends Expression {
|
class InsertExpression extends Expression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* argument
|
* argument
|
||||||
* @var object
|
* @var object
|
||||||
|
|
@ -19,25 +20,29 @@
|
||||||
* @param object $argument
|
* @param object $argument
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function InsertExpression($column_name, $argument){
|
function InsertExpression($column_name, $argument)
|
||||||
|
{
|
||||||
parent::Expression($column_name);
|
parent::Expression($column_name);
|
||||||
$this->argument = $argument;
|
$this->argument = $argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue($with_values = true){
|
function getValue($with_values = true)
|
||||||
|
{
|
||||||
if($with_values)
|
if($with_values)
|
||||||
return $this->argument->getValue();
|
return $this->argument->getValue();
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(){
|
function show()
|
||||||
|
{
|
||||||
if(!$this->argument) return false;
|
if(!$this->argument) return false;
|
||||||
$value = $this->argument->getValue();
|
$value = $this->argument->getValue();
|
||||||
if(!isset($value)) return false;
|
if(!isset($value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return $this->argument;
|
return $this->argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,6 +53,6 @@
|
||||||
else
|
else
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file InsertExpression.class.php */
|
||||||
?>
|
/* Location: ./classes/db/queryparts/expression/InsertExpression.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* SelectExpression
|
* SelectExpression
|
||||||
* Represents an expresion that appears in the select clause
|
* Represents an expresion that appears in the select clause
|
||||||
*
|
*
|
||||||
|
|
@ -13,7 +13,8 @@
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class SelectExpression extends Expression {
|
class SelectExpression extends Expression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* column alias name
|
* column alias name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -26,7 +27,8 @@
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function SelectExpression($column_name, $alias = NULL){
|
function SelectExpression($column_name, $alias = NULL)
|
||||||
|
{
|
||||||
parent::Expression($column_name);
|
parent::Expression($column_name);
|
||||||
$this->column_alias = $alias;
|
$this->column_alias = $alias;
|
||||||
}
|
}
|
||||||
|
|
@ -35,15 +37,18 @@
|
||||||
* Return column expression, ex) column as alias
|
* Return column expression, ex) column as alias
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpression() {
|
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() {
|
function show()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,8 +57,10 @@
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSubquery(){
|
function isSubquery()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file SelectExpression.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/expression/SelectExpression.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* StarExpression
|
* StarExpression
|
||||||
* Represents the * in 'select * from ...' statements
|
* Represents the * in 'select * from ...' statements
|
||||||
*
|
*
|
||||||
|
|
@ -7,22 +7,27 @@
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class StarExpression extends SelectExpression {
|
class StarExpression extends SelectExpression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* constructor, set the column to asterisk
|
* constructor, set the column to asterisk
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function StarExpression(){
|
function StarExpression()
|
||||||
|
{
|
||||||
parent::SelectExpression("*");
|
parent::SelectExpression("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
// StarExpression has no arguments
|
// StarExpression has no arguments
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file StarExpression.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/expression/StarExpression.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* UpdateExpression
|
* UpdateExpression
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class UpdateExpression extends Expression {
|
class UpdateExpression extends Expression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* argument
|
* argument
|
||||||
* @var object
|
* @var object
|
||||||
|
|
@ -19,7 +20,8 @@
|
||||||
* @param object $argument
|
* @param object $argument
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function UpdateExpression($column_name, $argument){
|
function UpdateExpression($column_name, $argument)
|
||||||
|
{
|
||||||
parent::Expression($column_name);
|
parent::Expression($column_name);
|
||||||
$this->argument = $argument;
|
$this->argument = $argument;
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +30,8 @@
|
||||||
* Return column expression, ex) column = value
|
* Return column expression, ex) column = value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpression($with_value = true){
|
function getExpression($with_value = true)
|
||||||
|
{
|
||||||
if($with_value)
|
if($with_value)
|
||||||
return $this->getExpressionWithValue();
|
return $this->getExpressionWithValue();
|
||||||
return $this->getExpressionWithoutValue();
|
return $this->getExpressionWithoutValue();
|
||||||
|
|
@ -38,7 +41,8 @@
|
||||||
* Return column expression, ex) column = value
|
* Return column expression, ex) column = value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpressionWithValue(){
|
function getExpressionWithValue()
|
||||||
|
{
|
||||||
$value = $this->argument->getValue();
|
$value = $this->argument->getValue();
|
||||||
$operation = $this->argument->getColumnOperation();
|
$operation = $this->argument->getColumnOperation();
|
||||||
if(isset($operation))
|
if(isset($operation))
|
||||||
|
|
@ -51,28 +55,32 @@
|
||||||
* Can use prepare statement
|
* Can use prepare statement
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpressionWithoutValue(){
|
function getExpressionWithoutValue()
|
||||||
|
{
|
||||||
$operation = $this->argument->getColumnOperation();
|
$operation = $this->argument->getColumnOperation();
|
||||||
if(isset($operation))
|
if(isset($operation))
|
||||||
return "$this->column_name = $this->column_name $operation ?";
|
return "$this->column_name = $this->column_name $operation ?";
|
||||||
return "$this->column_name = ?";
|
return "$this->column_name = ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(){
|
function getValue()
|
||||||
|
{
|
||||||
// TODO Escape value according to column type instead of variable type
|
// TODO Escape value according to column type instead of variable type
|
||||||
$value = $this->argument->getValue();
|
$value = $this->argument->getValue();
|
||||||
if(!is_numeric($value)) return "'".$value."'";
|
if(!is_numeric($value)) return "'".$value."'";
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(){
|
function show()
|
||||||
|
{
|
||||||
if(!$this->argument) return false;
|
if(!$this->argument) return false;
|
||||||
$value = $this->argument->getValue();
|
$value = $this->argument->getValue();
|
||||||
if(!isset($value)) return false;
|
if(!isset($value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return $this->argument;
|
return $this->argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +91,7 @@
|
||||||
else
|
else
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* End of file UpdateExpression.class.php */
|
||||||
?>
|
/* Location: ./classes/db/queryparts/expression/UpdateExpression.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* UpdateExpression
|
* UpdateExpression
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/db/queryparts/expression
|
* @package /classes/db/queryparts/expression
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class UpdateExpressionWithoutArgument extends UpdateExpression {
|
class UpdateExpressionWithoutArgument extends UpdateExpression
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* argument
|
* argument
|
||||||
* @var object
|
* @var object
|
||||||
|
|
@ -19,37 +20,42 @@
|
||||||
* @param object $argument
|
* @param object $argument
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function UpdateExpressionWithoutArgument($column_name, $argument){
|
function UpdateExpressionWithoutArgument($column_name, $argument)
|
||||||
|
{
|
||||||
parent::Expression($column_name);
|
parent::Expression($column_name);
|
||||||
$this->argument = $argument;
|
$this->argument = $argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpression($with_value = true){
|
function getExpression($with_value = true)
|
||||||
|
{
|
||||||
return "$this->column_name = $this->argument";
|
return "$this->column_name = $this->argument";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(){
|
function getValue()
|
||||||
|
{
|
||||||
// TODO Escape value according to column type instead of variable type
|
// TODO Escape value according to column type instead of variable type
|
||||||
$value = $this->argument;
|
$value = $this->argument;
|
||||||
if(!is_numeric($value)) return "'".$value."'";
|
if(!is_numeric($value)) return "'".$value."'";
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(){
|
function show()
|
||||||
|
{
|
||||||
if(!$this->argument) return false;
|
if(!$this->argument) return false;
|
||||||
$value = $this->argument;
|
$value = $this->argument;
|
||||||
if(!isset($value)) return false;
|
if(!isset($value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file UpdateExpressionWithoutArgument.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php */
|
||||||
?>
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/limit
|
* @package /classes/db/queryparts/limit
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class Limit {
|
class Limit
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* start number
|
* start number
|
||||||
* @var int
|
* @var int
|
||||||
|
|
@ -33,9 +34,11 @@
|
||||||
* @param int $page_count
|
* @param int $page_count
|
||||||
* @return void
|
* @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;
|
$this->list_count = $list_count;
|
||||||
if ($page){
|
if ($page)
|
||||||
|
{
|
||||||
$list_count_value = $list_count->getValue();
|
$list_count_value = $list_count->getValue();
|
||||||
$page_value = $page->getValue();
|
$page_value = $page->getValue();
|
||||||
$this->start = ($page_value - 1) * $list_count_value;
|
$this->start = ($page_value - 1) * $list_count_value;
|
||||||
|
|
@ -48,22 +51,27 @@
|
||||||
* 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
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isPageHandler(){
|
function isPageHandler()
|
||||||
|
{
|
||||||
if ($this->page)return true;
|
if ($this->page)return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOffset(){
|
function getOffset()
|
||||||
|
{
|
||||||
return $this->start;
|
return $this->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLimit(){
|
function getLimit()
|
||||||
|
{
|
||||||
return $this->list_count->getValue();
|
return $this->list_count->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
if ($this->page) return $this->start . ' , ' . $this->list_count->getValue();
|
if ($this->page) return $this->start . ' , ' . $this->list_count->getValue();
|
||||||
else return $this->list_count->getValue();
|
else return $this->list_count->getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file Limit.class.php */
|
||||||
|
/* Location: ./classes/db/limit/Limit.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/order
|
* @package /classes/db/queryparts/order
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class OrderByColumn {
|
class OrderByColumn
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* column name
|
* column name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -22,29 +23,33 @@
|
||||||
* @param string $sort_order
|
* @param string $sort_order
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function OrderByColumn($column_name, $sort_order){
|
function OrderByColumn($column_name, $sort_order)
|
||||||
|
{
|
||||||
$this->column_name = $column_name;
|
$this->column_name = $column_name;
|
||||||
$this->sort_order = $sort_order;
|
$this->sort_order = $sort_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$result = $this->getColumnName();
|
$result = $this->getColumnName();
|
||||||
$result .= ' ';
|
$result .= ' ';
|
||||||
$result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
|
$result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColumnName(){
|
function getColumnName()
|
||||||
|
{
|
||||||
return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
|
return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$args = array();
|
$args = array();
|
||||||
if(is_a($this->column_name, 'Argument'))
|
if(is_a($this->column_name, 'Argument'))
|
||||||
$args[]= $this->column_name;
|
$args[]= $this->column_name;
|
||||||
if(is_a($this->sort_order, 'Argument'))
|
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 */
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/table
|
* @package /classes/db/queryparts/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class CubridTableWithHint extends Table {
|
class CubridTableWithHint extends Table
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* table name
|
* table name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -28,7 +29,8 @@
|
||||||
* @param array $index_hints_list
|
* @param array $index_hints_list
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function CubridTableWithHint($name, $alias = NULL, $index_hints_list){
|
function CubridTableWithHint($name, $alias = NULL, $index_hints_list)
|
||||||
|
{
|
||||||
parent::Table($name, $alias);
|
parent::Table($name, $alias);
|
||||||
$this->index_hints_list = $index_hints_list;
|
$this->index_hints_list = $index_hints_list;
|
||||||
}
|
}
|
||||||
|
|
@ -37,26 +39,28 @@
|
||||||
* Return index hint string
|
* Return index hint string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getIndexHintString(){
|
function getIndexHintString()
|
||||||
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
|
|
||||||
// Retrieve table prefix, to add it to index name
|
// Retrieve table prefix, to add it to index name
|
||||||
$db_info = Context::getDBInfo();
|
$db_info = Context::getDBInfo();
|
||||||
$prefix = $db_info->master_db["db_table_prefix"];
|
$prefix = $db_info->master_db["db_table_prefix"];
|
||||||
|
|
||||||
foreach($this->index_hints_list as $index_hint){
|
foreach($this->index_hints_list as $index_hint)
|
||||||
|
{
|
||||||
$index_hint_type = $index_hint->getIndexHintType();
|
$index_hint_type = $index_hint->getIndexHintType();
|
||||||
if($index_hint_type !== 'IGNORE'){
|
if($index_hint_type !== 'IGNORE')
|
||||||
|
{
|
||||||
$result .= $this->alias . '.'
|
$result .= $this->alias . '.'
|
||||||
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
|
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
|
||||||
. ($index_hint_type == 'FORCE' ? '(+)' : '')
|
. ($index_hint_type == 'FORCE' ? '(+)' : '')
|
||||||
. ', ';
|
. ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$result = substr($result, 0, -2);
|
$result = substr($result, 0, -2);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file CubridTableWithHint.class.php */
|
||||||
?>
|
/* Location: ./classes/db/queryparts/table/CubridTableWithHint.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/table
|
* @package /classes/db/queryparts/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class IndexHint {
|
class IndexHint
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* index name
|
* index name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -22,18 +23,21 @@
|
||||||
* @param string $index_hint_type
|
* @param string $index_hint_type
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function IndexHint($index_name, $index_hint_type){
|
function IndexHint($index_name, $index_hint_type)
|
||||||
|
{
|
||||||
$this->index_name = $index_name;
|
$this->index_name = $index_name;
|
||||||
$this->index_hint_type = $index_hint_type;
|
$this->index_hint_type = $index_hint_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIndexName(){
|
function getIndexName()
|
||||||
|
{
|
||||||
return $this->index_name;
|
return $this->index_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIndexHintType() {
|
function getIndexHintType()
|
||||||
|
{
|
||||||
return $this->index_hint_type;
|
return $this->index_hint_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file IndexHint.class.php */
|
||||||
?>
|
/* Location: ./classes/db/queryparts/table/IndexHint.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* class JoinTable
|
* class JoinTable
|
||||||
* $conditions in an array of Condition objects
|
* $conditions in an array of Condition objects
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/db/queryparts/table
|
* @package /classes/db/queryparts/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class JoinTable extends Table {
|
class JoinTable extends Table
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* join type
|
* join type
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -27,13 +28,15 @@
|
||||||
* @param array $conditions
|
* @param array $conditions
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function JoinTable($name, $alias, $join_type, $conditions){
|
function JoinTable($name, $alias, $join_type, $conditions)
|
||||||
|
{
|
||||||
parent::Table($name, $alias);
|
parent::Table($name, $alias);
|
||||||
$this->join_type = $join_type;
|
$this->join_type = $join_type;
|
||||||
$this->conditions = $conditions;
|
$this->conditions = $conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString($with_value = true){
|
function toString($with_value = true)
|
||||||
|
{
|
||||||
$part = $this->join_type . ' ' . $this->name ;
|
$part = $this->join_type . ' ' . $this->name ;
|
||||||
$part .= $this->alias ? ' as ' . $this->alias : '';
|
$part .= $this->alias ? ' as ' . $this->alias : '';
|
||||||
$part .= ' on ';
|
$part .= ' on ';
|
||||||
|
|
@ -42,7 +45,8 @@
|
||||||
return $part;
|
return $part;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJoinTable(){
|
function isJoinTable()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,7 +57,6 @@
|
||||||
$args = array_merge($args, $conditionGroup->getArguments());
|
$args = array_merge($args, $conditionGroup->getArguments());
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
/* End of file JoinTable.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/table/JoinTable.class.php */
|
||||||
?>
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/table
|
* @package /classes/db/queryparts/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class MssqlTableWithHint extends Table {
|
class MssqlTableWithHint extends Table
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* table name
|
* table name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -28,26 +29,30 @@
|
||||||
* @param string $index_hints_list
|
* @param string $index_hints_list
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list){
|
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list)
|
||||||
|
{
|
||||||
parent::Table($name, $alias);
|
parent::Table($name, $alias);
|
||||||
$this->index_hints_list = $index_hints_list;
|
$this->index_hints_list = $index_hints_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$result = parent::toString();
|
$result = parent::toString();
|
||||||
|
|
||||||
$index_hint_string = '';
|
$index_hint_string = '';
|
||||||
$indexTypeList = array('USE'=>1, 'FORCE'=>1);
|
$indexTypeList = array('USE'=>1, 'FORCE'=>1);
|
||||||
foreach($this->index_hints_list as $index_hint){
|
foreach($this->index_hints_list as $index_hint)
|
||||||
|
{
|
||||||
$index_hint_type = $index_hint->getIndexHintType();
|
$index_hint_type = $index_hint->getIndexHintType();
|
||||||
if(isset($indexTypeList[$index_hint_type]))
|
if(isset($indexTypeList[$index_hint_type]))
|
||||||
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
|
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
|
||||||
}
|
}
|
||||||
if($index_hint_string != ''){
|
if($index_hint_string != '')
|
||||||
|
{
|
||||||
$result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
|
$result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file MssqlTableWithHint.class.php */
|
||||||
?>
|
/* Location: ./classes/db/queryparts/table/MssqlTableWithHint.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/table
|
* @package /classes/db/queryparts/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class MysqlTableWithHint extends Table {
|
class MysqlTableWithHint extends Table
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* table name
|
* table name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -28,32 +29,38 @@
|
||||||
* @param string $index_hints_list
|
* @param string $index_hints_list
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function MysqlTableWithHint($name, $alias = NULL, $index_hints_list){
|
function MysqlTableWithHint($name, $alias = NULL, $index_hints_list)
|
||||||
|
{
|
||||||
parent::Table($name, $alias);
|
parent::Table($name, $alias);
|
||||||
$this->index_hints_list = $index_hints_list;
|
$this->index_hints_list = $index_hints_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$result = parent::toString();
|
$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){
|
foreach($this->index_hints_list as $index_hint)
|
||||||
|
{
|
||||||
$index_hint_type = $index_hint->getIndexHintType();
|
$index_hint_type = $index_hint->getIndexHintType();
|
||||||
if($index_hint_type == 'USE') $use_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 == 'FORCE') $force_index_hint .= $index_hint->getIndexName() . ', ';
|
||||||
else if($index_hint_type == 'IGNORE') $ignore_index_hint .= $index_hint->getIndexName() . ', ';
|
else if($index_hint_type == 'IGNORE') $ignore_index_hint .= $index_hint->getIndexName() . ', ';
|
||||||
}
|
}
|
||||||
if($use_index_hint != ''){
|
if($use_index_hint != '')
|
||||||
|
{
|
||||||
$result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
|
$result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
|
||||||
}
|
}
|
||||||
if($force_index_hint != ''){
|
if($force_index_hint != '')
|
||||||
|
{
|
||||||
$result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
|
$result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
|
||||||
}
|
}
|
||||||
if($ignore_index_hint != ''){
|
if($ignore_index_hint != '')
|
||||||
|
{
|
||||||
$result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
|
$result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file MysqlTableWithHint.class.php */
|
||||||
?>
|
/* Location: ./classes/db/queryparts/table/MysqlTableWithHint.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/db/queryparts/table
|
* @package /classes/db/queryparts/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class Table {
|
class Table
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* table name
|
* table name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -22,27 +23,33 @@
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Table($name, $alias = NULL){
|
function Table($name, $alias = NULL)
|
||||||
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->alias = $alias;
|
$this->alias = $alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
//return $this->name;
|
//return $this->name;
|
||||||
return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : '');
|
return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName(){
|
function getName()
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlias(){
|
function getAlias()
|
||||||
|
{
|
||||||
return $this->alias;
|
return $this->alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJoinTable(){
|
function isJoinTable()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
/* End of file Table.class.php */
|
||||||
|
/* Location: ./classes/db/queryparts/table/Table.class.php */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue