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
<?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 */