mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 04:24:14 +09:00
issue 262 coding convention in classes
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12230 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cf271c0a98
commit
d5a46e5e90
27 changed files with 1840 additions and 1625 deletions
|
|
@ -346,4 +346,4 @@ class Argument
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* End of file Argument.class.php */
|
/* End of file Argument.class.php */
|
||||||
/* Location: ./classes/xml/xmlquery/Argument.class.php */
|
/* Location: ./classes/xml/xmlquery/argument/Argument.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ConditionArgument class
|
* ConditionArgument class
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/xml/xmlquery/argument
|
* @package /classes/xml/xmlquery/argument
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class ConditionArgument extends Argument {
|
class ConditionArgument extends Argument
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Operator keyword. for example 'in', 'notint', 'between'
|
* Operator keyword. for example 'in', 'notint', 'between'
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $operation;
|
var $operation;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
|
@ -20,9 +20,11 @@
|
||||||
* @param string $operation
|
* @param string $operation
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ConditionArgument($name, $value, $operation){
|
function ConditionArgument($name, $value, $operation)
|
||||||
|
{
|
||||||
$operationList = array('in'=>1, 'notin'=>1, 'not_in'=>1, 'between'=>1);
|
$operationList = array('in'=>1, 'notin'=>1, 'not_in'=>1, 'between'=>1);
|
||||||
if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != ''){
|
if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '')
|
||||||
|
{
|
||||||
$value = str_replace(' ', '', $value);
|
$value = str_replace(' ', '', $value);
|
||||||
$value = str_replace('\'', '', $value);
|
$value = str_replace('\'', '', $value);
|
||||||
$value = explode(',', $value);
|
$value = explode(',', $value);
|
||||||
|
|
@ -35,31 +37,32 @@
|
||||||
* create condition value. set $this->value
|
* create condition value. set $this->value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function createConditionValue(){
|
function createConditionValue()
|
||||||
|
{
|
||||||
if(!isset($this->value)) return;
|
if(!isset($this->value)) return;
|
||||||
|
|
||||||
$operation = $this->operation;
|
$operation = $this->operation;
|
||||||
$value = $this->value;
|
$value = $this->value;
|
||||||
|
|
||||||
switch($operation) {
|
switch($operation)
|
||||||
|
{
|
||||||
case 'like_prefix' :
|
case 'like_prefix' :
|
||||||
if(defined('__CUBRID_VERSION__')
|
if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1')
|
||||||
&& __CUBRID_VERSION__ >= '8.4.1') {
|
{
|
||||||
$this->value = '^' . str_replace('%', '(.*)', preg_quote($value));
|
$this->value = '^' . str_replace('%', '(.*)', preg_quote($value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->value = $value.'%';
|
$this->value = $value.'%';
|
||||||
break;
|
break;
|
||||||
case 'like_tail' :
|
case 'like_tail' :
|
||||||
if(defined('__CUBRID_VERSION__')
|
if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1')
|
||||||
&& __CUBRID_VERSION__ >= '8.4.1')
|
|
||||||
$this->value = str_replace('%', '(.*)', preg_quote($value)) . '$';
|
$this->value = str_replace('%', '(.*)', preg_quote($value)) . '$';
|
||||||
else
|
else
|
||||||
$this->value = '%'.$value;
|
$this->value = '%'.$value;
|
||||||
break;
|
break;
|
||||||
case 'like' :
|
case 'like' :
|
||||||
if(defined('__CUBRID_VERSION__')
|
if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1')
|
||||||
&& __CUBRID_VERSION__ >= '8.4.1') {
|
{
|
||||||
$this->value = str_replace('%', '(.*)', preg_quote($value));
|
$this->value = str_replace('%', '(.*)', preg_quote($value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -95,7 +98,8 @@
|
||||||
*
|
*
|
||||||
* @return type string
|
* @return type string
|
||||||
*/
|
*/
|
||||||
function getType(){
|
function getType()
|
||||||
|
{
|
||||||
if($this->type)
|
if($this->type)
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
|
|
@ -110,13 +114,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setColumnType($column_type){
|
function setColumnType($column_type)
|
||||||
|
{
|
||||||
if(!isset($this->value)) return;
|
if(!isset($this->value)) return;
|
||||||
if($column_type === '') return;
|
if($column_type === '') return;
|
||||||
|
|
||||||
$this->type = $column_type;
|
$this->type = $column_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* End of file ConditionArgument.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/argument/ConditionArgument.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* SortArgument class
|
* SortArgument class
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/xml/xmlquery/argument
|
* @package /classes/xml/xmlquery/argument
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class SortArgument extends Argument {
|
class SortArgument extends Argument
|
||||||
|
{
|
||||||
function getValue(){
|
function getValue()
|
||||||
|
{
|
||||||
return $this->getUnescapedValue();
|
return $this->getUnescapedValue();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
/* End of file SortArgument.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/argument/SortArgument.class.php */
|
||||||
?>
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* DefaultValue class
|
* DefaultValue class
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/xml/xmlquery/queryargument
|
* @package /classes/xml/xmlquery/queryargument
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class DefaultValue {
|
class DefaultValue
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Column name
|
* Column name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -48,48 +49,57 @@
|
||||||
* @param mixed $value value
|
* @param mixed $value value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function DefaultValue($column_name, $value){
|
function DefaultValue($column_name, $value)
|
||||||
|
{
|
||||||
$dbParser = &DB::getParser();
|
$dbParser = &DB::getParser();
|
||||||
$this->column_name = $dbParser->parseColumnName($column_name);
|
$this->column_name = $dbParser->parseColumnName($column_name);
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
$this->value = $this->_setValue();
|
$this->value = $this->_setValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isString(){
|
function isString()
|
||||||
|
{
|
||||||
return $this->_is_string;
|
return $this->_is_string;
|
||||||
$str_pos = strpos($this->value, '(');
|
$str_pos = strpos($this->value, '(');
|
||||||
if($str_pos===false) return true;
|
if($str_pos===false) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStringFromFunction(){
|
function isStringFromFunction()
|
||||||
|
{
|
||||||
return $this->_is_string_from_function;
|
return $this->_is_string_from_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSequence(){
|
function isSequence()
|
||||||
|
{
|
||||||
return $this->is_sequence;
|
return $this->is_sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOperation(){
|
function isOperation()
|
||||||
|
{
|
||||||
return $this->is_operation;
|
return $this->is_operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOperation(){
|
function getOperation()
|
||||||
|
{
|
||||||
return $this->operation;
|
return $this->operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setValue(){
|
function _setValue()
|
||||||
|
{
|
||||||
if(!isset($this->value)) return;
|
if(!isset($this->value)) return;
|
||||||
|
|
||||||
// If value contains comma separated values and does not contain paranthesis
|
// If value contains comma separated values and does not contain paranthesis
|
||||||
// -> default value is an array
|
// -> default value is an array
|
||||||
if(strpos($this->value, ',') !== false && strpos($this->value, '(') === false) {
|
if(strpos($this->value, ',') !== false && strpos($this->value, '(') === false)
|
||||||
|
{
|
||||||
return sprintf('array(%s)', $this->value);
|
return sprintf('array(%s)', $this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_pos = strpos($this->value, '(');
|
$str_pos = strpos($this->value, '(');
|
||||||
// // TODO Replace this with parseExpression
|
// // TODO Replace this with parseExpression
|
||||||
if($str_pos===false) {
|
if($str_pos===false)
|
||||||
|
{
|
||||||
$this->_is_string = true;
|
$this->_is_string = true;
|
||||||
return '\''.$this->value.'\'';
|
return '\''.$this->value.'\'';
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +108,8 @@
|
||||||
$func_name = substr($this->value, 0, $str_pos);
|
$func_name = substr($this->value, 0, $str_pos);
|
||||||
$args = substr($this->value, $str_pos+1, -1);
|
$args = substr($this->value, $str_pos+1, -1);
|
||||||
|
|
||||||
switch($func_name) {
|
switch($func_name)
|
||||||
|
{
|
||||||
case 'ipaddress' :
|
case 'ipaddress' :
|
||||||
$val = '$_SERVER[\'REMOTE_ADDR\']';
|
$val = '$_SERVER[\'REMOTE_ADDR\']';
|
||||||
$this->_is_string_from_function = true;
|
$this->_is_string_from_function = true;
|
||||||
|
|
@ -140,7 +151,10 @@
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file DefaultValue.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/queryargument/DefaultValue.class.php */
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
* @package /classes/xml/xmlquery/queryargument
|
* @package /classes/xml/xmlquery/queryargument
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class QueryArgument {
|
class QueryArgument
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Argument name
|
* Argument name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -48,13 +49,14 @@ class QueryArgument {
|
||||||
* @param bool $ignore_value
|
* @param bool $ignore_value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function QueryArgument($tag, $ignore_value = false) {
|
function QueryArgument($tag, $ignore_value = false)
|
||||||
|
{
|
||||||
static $number_of_arguments = 0;
|
static $number_of_arguments = 0;
|
||||||
|
|
||||||
$this->argument_name = $tag->attrs->var;
|
$this->argument_name = $tag->attrs->var;
|
||||||
if (!$this->argument_name)
|
if(!$this->argument_name)
|
||||||
$this->argument_name = str_replace('.', '_', $tag->attrs->name);
|
$this->argument_name = str_replace('.', '_', $tag->attrs->name);
|
||||||
if (!$this->argument_name)
|
if(!$this->argument_name)
|
||||||
$this->argument_name = str_replace('.', '_', $tag->attrs->column);
|
$this->argument_name = str_replace('.', '_', $tag->attrs->column);
|
||||||
|
|
||||||
$this->variable_name = $this->argument_name;
|
$this->variable_name = $this->argument_name;
|
||||||
|
|
@ -63,41 +65,47 @@ class QueryArgument {
|
||||||
$this->argument_name .= $number_of_arguments;
|
$this->argument_name .= $number_of_arguments;
|
||||||
|
|
||||||
$name = $tag->attrs->name;
|
$name = $tag->attrs->name;
|
||||||
if (!$name)
|
if(!$name)
|
||||||
$name = $tag->attrs->column;
|
$name = $tag->attrs->column;
|
||||||
if (strpos($name, '.') === false)
|
if(strpos($name, '.') === false)
|
||||||
$this->column_name = $name;
|
$this->column_name = $name;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
list($prefix, $name) = explode('.', $name);
|
list($prefix, $name) = explode('.', $name);
|
||||||
$this->column_name = $name;
|
$this->column_name = $name;
|
||||||
$this->table_name = $prefix;
|
$this->table_name = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tag->attrs->operation)
|
if($tag->attrs->operation)
|
||||||
$this->operation = $tag->attrs->operation;
|
$this->operation = $tag->attrs->operation;
|
||||||
|
|
||||||
$this->argument_validator = new QueryArgumentValidator($tag, $this);
|
$this->argument_validator = new QueryArgumentValidator($tag, $this);
|
||||||
$this->ignore_value = $ignore_value;
|
$this->ignore_value = $ignore_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgumentName() {
|
function getArgumentName()
|
||||||
|
{
|
||||||
return $this->argument_name;
|
return $this->argument_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColumnName() {
|
function getColumnName()
|
||||||
|
{
|
||||||
return $this->column_name;
|
return $this->column_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableName(){
|
function getTableName()
|
||||||
|
{
|
||||||
return $this->table_name;
|
return $this->table_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValidatorString() {
|
function getValidatorString()
|
||||||
|
{
|
||||||
return $this->argument_validator->toString();
|
return $this->argument_validator->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isConditionArgument() {
|
function isConditionArgument()
|
||||||
if ($this->operation)
|
{
|
||||||
|
if($this->operation)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -106,8 +114,10 @@ class QueryArgument {
|
||||||
* Change QueryArgument object to string
|
* Change QueryArgument object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString() {
|
function toString()
|
||||||
if ($this->isConditionArgument()) {
|
{
|
||||||
|
if($this->isConditionArgument())
|
||||||
|
{
|
||||||
// Instantiation
|
// Instantiation
|
||||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new ConditionArgument(\'%s\', %s, \'%s\');' . "\n"
|
$arg = sprintf("\n" . '${\'%s_argument\'} = new ConditionArgument(\'%s\', %s, \'%s\');' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
|
|
@ -128,7 +138,9 @@ class QueryArgument {
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new Argument(\'%s\', %s);' . "\n"
|
$arg = sprintf("\n" . '${\'%s_argument\'} = new Argument(\'%s\', %s);' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->variable_name
|
, $this->variable_name
|
||||||
|
|
@ -143,7 +155,8 @@ class QueryArgument {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the argument is null, skip it
|
// If the argument is null, skip it
|
||||||
if ($this->argument_validator->isIgnorable()) {
|
if($this->argument_validator->isIgnorable())
|
||||||
|
{
|
||||||
$arg = sprintf("if(isset(%s)) {", '$args->' . $this->variable_name)
|
$arg = sprintf("if(isset(%s)) {", '$args->' . $this->variable_name)
|
||||||
. $arg
|
. $arg
|
||||||
. sprintf("} else\n" . '${\'%s_argument\'} = null;', $this->argument_name);
|
. sprintf("} else\n" . '${\'%s_argument\'} = null;', $this->argument_name);
|
||||||
|
|
@ -151,7 +164,6 @@ class QueryArgument {
|
||||||
|
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* End of file QueryArgument.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/queryargument/QueryArgument.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* SortQueryArgument class
|
* SortQueryArgument class
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/xml/xmlquery/queryargument
|
* @package /classes/xml/xmlquery/queryargument
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class SortQueryArgument extends QueryArgument{
|
class SortQueryArgument extends QueryArgument
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Change SortQueryArgument object to string
|
* Change SortQueryArgument object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$arg = sprintf("\n" . '${\'%s_argument\'} = new SortArgument(\'%s\', %s);' . "\n"
|
$arg = sprintf("\n" . '${\'%s_argument\'} = new SortArgument(\'%s\', %s);' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, '$args->'.$this->variable_name);
|
, '$args->'.$this->variable_name);
|
||||||
|
|
||||||
|
|
||||||
$arg .= $this->argument_validator->toString();
|
$arg .= $this->argument_validator->toString();
|
||||||
|
|
||||||
$arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n"
|
$arg .= sprintf('if(!${\'%s_argument\'}->isValid()) return ${\'%s_argument\'}->getErrorMessage();' . "\n"
|
||||||
|
|
@ -25,5 +25,6 @@
|
||||||
);
|
);
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file DefaultValue.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/queryargument/DefaultValue.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* QueryArgumentValidator class
|
* QueryArgumentValidator class
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* @package /classes/xml/xmlquery/queryargument/validator
|
* @package /classes/xml/xmlquery/queryargument/validator
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class QueryArgumentValidator {
|
class QueryArgumentValidator
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Argument name
|
* Argument name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -51,7 +52,8 @@
|
||||||
* @param QueryArgument $argument
|
* @param QueryArgument $argument
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function QueryArgumentValidator($tag, $argument){
|
function QueryArgumentValidator($tag, $argument)
|
||||||
|
{
|
||||||
$this->argument = $argument;
|
$this->argument = $argument;
|
||||||
$this->argument_name = $this->argument->getArgumentName();
|
$this->argument_name = $this->argument->getArgumentName();
|
||||||
|
|
||||||
|
|
@ -62,52 +64,62 @@
|
||||||
$this->max_length = $tag->attrs->max_length;
|
$this->max_length = $tag->attrs->max_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isIgnorable(){
|
function isIgnorable()
|
||||||
|
{
|
||||||
if(isset($this->default_value) || isset($this->notnull)) return false;
|
if(isset($this->default_value) || isset($this->notnull)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$validator = '';
|
$validator = '';
|
||||||
if($this->filter){
|
if($this->filter)
|
||||||
|
{
|
||||||
$validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');' . "\n"
|
$validator .= sprintf('${\'%s_argument\'}->checkFilter(\'%s\');' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->filter
|
, $this->filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if($this->min_length){
|
if($this->min_length)
|
||||||
|
{
|
||||||
$validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);' . "\n"
|
$validator .= sprintf('${\'%s_argument\'}->checkMinLength(%s);' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->min_length
|
, $this->min_length
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if($this->max_length){
|
if($this->max_length)
|
||||||
|
{
|
||||||
$validator .= sprintf('${\'%s_argument\'}->checkMaxLength(%s);'. "\n"
|
$validator .= sprintf('${\'%s_argument\'}->checkMaxLength(%s);'. "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->max_length
|
, $this->max_length
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(isset($this->default_value)){
|
if(isset($this->default_value))
|
||||||
|
{
|
||||||
$this->default_value = new DefaultValue($this->argument_name, $this->default_value);
|
$this->default_value = new DefaultValue($this->argument_name, $this->default_value);
|
||||||
if($this->default_value->isSequence())
|
if($this->default_value->isSequence())
|
||||||
$validator .= '$db = &DB::getInstance(); $sequence = $db->getNextSequence(); ';
|
$validator .= '$db = &DB::getInstance(); $sequence = $db->getNextSequence(); ';
|
||||||
if($this->default_value->isOperation())
|
if($this->default_value->isOperation())
|
||||||
|
{
|
||||||
$validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n"
|
$validator .= sprintf('${\'%s_argument\'}->setColumnOperation(\'%s\');' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->default_value->getOperation()
|
, $this->default_value->getOperation()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
$validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);' . "\n"
|
$validator .= sprintf('${\'%s_argument\'}->ensureDefaultValue(%s);' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->default_value->toString()
|
, $this->default_value->toString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if($this->notnull){
|
if($this->notnull)
|
||||||
|
{
|
||||||
$validator .= sprintf('${\'%s_argument\'}->checkNotNull();' . "\n"
|
$validator .= sprintf('${\'%s_argument\'}->checkNotNull();' . "\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $validator;
|
return $validator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
/* End of file QueryArgumentValidator.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ColumnTag class
|
* ColumnTag class
|
||||||
* Models the <column> tag inside an XML Query file
|
* Models the <column> tag inside an XML Query file
|
||||||
* Since the <column> tag supports different attributes depending on
|
* Since the <column> tag supports different attributes depending on
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class ColumnTag {
|
class ColumnTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Column name
|
* Column name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -22,7 +23,10 @@
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ColumnTag($name){
|
function ColumnTag($name)
|
||||||
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file ColumnTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/column/ColumnTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* InsertColumnTag
|
* InsertColumnTag
|
||||||
* Models the <column> tag inside an XML Query file whose action is 'insert'
|
* Models the <column> tag inside an XML Query file whose action is 'insert'
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class InsertColumnTag extends ColumnTag {
|
class InsertColumnTag extends ColumnTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* argument
|
* argument
|
||||||
* @var QueryArgument object
|
* @var QueryArgument object
|
||||||
|
|
@ -19,22 +20,26 @@
|
||||||
* @param object $column
|
* @param object $column
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function InsertColumnTag($column) {
|
function InsertColumnTag($column)
|
||||||
|
{
|
||||||
parent::ColumnTag($column->attrs->name);
|
parent::ColumnTag($column->attrs->name);
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$this->name = $dbParser->parseColumnName($this->name);
|
$this->name = $dbParser->parseColumnName($this->name);
|
||||||
$this->argument = new QueryArgument($column);
|
$this->argument = new QueryArgument($column);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpressionString(){
|
function getExpressionString()
|
||||||
|
{
|
||||||
return sprintf('new InsertExpression(\'%s\', ${\'%s_argument\'})'
|
return sprintf('new InsertExpression(\'%s\', ${\'%s_argument\'})'
|
||||||
, $this->name
|
, $this->name
|
||||||
, $this->argument->argument_name);
|
, $this->argument->argument_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return $this->argument;
|
return $this->argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
/* End of file InsertColumnTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/column/InsertColumnTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* InsertColumnTagWithoutArgument
|
* InsertColumnTagWithoutArgument
|
||||||
* Models the <column> tag inside an XML Query file whose action is 'insert-select'
|
* Models the <column> tag inside an XML Query file whose action is 'insert-select'
|
||||||
*
|
*
|
||||||
|
|
@ -7,25 +7,30 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class InsertColumnTagWithoutArgument extends ColumnTag {
|
class InsertColumnTagWithoutArgument extends ColumnTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
* @param object $column
|
* @param object $column
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function InsertColumnTagWithoutArgument($column) {
|
function InsertColumnTagWithoutArgument($column)
|
||||||
|
{
|
||||||
parent::ColumnTag($column->attrs->name);
|
parent::ColumnTag($column->attrs->name);
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$this->name = $dbParser->parseColumnName($this->name);
|
$this->name = $dbParser->parseColumnName($this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpressionString(){
|
function getExpressionString()
|
||||||
|
{
|
||||||
return sprintf('new Expression(\'%s\')', $this->name);
|
return sprintf('new Expression(\'%s\')', $this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
/* End of file InsertColumnTagWithoutArgument.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/column/InsertColumnTagWithoutArgument.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* InsertColumnsTag class
|
* InsertColumnsTag class
|
||||||
* Models the <column> tag inside an XML Query file whose action is 'insert'
|
* Models the <column> tag inside an XML Query file whose action is 'insert'
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class InsertColumnsTag{
|
class InsertColumnsTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Column list
|
* Column list
|
||||||
* @var array value is InsertColumnTag object
|
* @var array value is InsertColumnTag object
|
||||||
|
|
@ -19,7 +20,8 @@
|
||||||
* @param array|string $xml_columns
|
* @param array|string $xml_columns
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function InsertColumnsTag($xml_columns) {
|
function InsertColumnsTag($xml_columns)
|
||||||
|
{
|
||||||
$this->columns = array();
|
$this->columns = array();
|
||||||
|
|
||||||
if(!$xml_columns)
|
if(!$xml_columns)
|
||||||
|
|
@ -27,7 +29,8 @@
|
||||||
|
|
||||||
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
|
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
|
||||||
|
|
||||||
foreach($xml_columns as $column){
|
foreach($xml_columns as $column)
|
||||||
|
{
|
||||||
if($column->name === 'query') $this->columns[] = new QueryTag($column, true);
|
if($column->name === 'query') $this->columns[] = new QueryTag($column, true);
|
||||||
else if(!isset($column->attrs->var) && !isset($column->attrs->default)) $this->columns[] = new InsertColumnTagWithoutArgument($column);
|
else if(!isset($column->attrs->var) && !isset($column->attrs->default)) $this->columns[] = new InsertColumnTagWithoutArgument($column);
|
||||||
else $this->columns[] = new InsertColumnTag($column);
|
else $this->columns[] = new InsertColumnTag($column);
|
||||||
|
|
@ -38,9 +41,11 @@
|
||||||
* InsertColumnTag object to string
|
* InsertColumnTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$output_columns = 'array(' . PHP_EOL;
|
$output_columns = 'array(' . PHP_EOL;
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column)
|
||||||
|
{
|
||||||
$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
|
$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
|
||||||
}
|
}
|
||||||
$output_columns = substr($output_columns, 0, -1);
|
$output_columns = substr($output_columns, 0, -1);
|
||||||
|
|
@ -52,14 +57,16 @@
|
||||||
* Return argument list
|
* Return argument list
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column)
|
||||||
|
{
|
||||||
$arguments[] = $column->getArgument();
|
$arguments[] = $column->getArgument();
|
||||||
}
|
}
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* End of file InsertColumnsTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/column/InsertColumnsTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* SelectColumnTag
|
* SelectColumnTag
|
||||||
* Models the <column> tag inside an XML Query file whose action is 'select'
|
* Models the <column> tag inside an XML Query file whose action is 'select'
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class SelectColumnTag extends ColumnTag{
|
class SelectColumnTag extends ColumnTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* alias
|
* alias
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -24,7 +25,8 @@
|
||||||
* @param string|object $column
|
* @param string|object $column
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function SelectColumnTag($column){
|
function SelectColumnTag($column)
|
||||||
|
{
|
||||||
if ($column == "*" || $column->attrs->name == '*')
|
if ($column == "*" || $column->attrs->name == '*')
|
||||||
{
|
{
|
||||||
parent::ColumnTag(NULL);
|
parent::ColumnTag(NULL);
|
||||||
|
|
@ -41,7 +43,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpressionString(){
|
function getExpressionString()
|
||||||
|
{
|
||||||
if($this->name == '*') return "new StarExpression()";
|
if($this->name == '*') return "new StarExpression()";
|
||||||
if($this->click_count)
|
if($this->click_count)
|
||||||
return sprintf('new ClickCountExpression(%s, %s, $args->%s)', $this->name, $this->alias,$this->click_count);
|
return sprintf('new ClickCountExpression(%s, %s, $args->%s)', $this->name, $this->alias,$this->click_count);
|
||||||
|
|
@ -50,4 +53,6 @@
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
return sprintf('new SelectExpression(\'%s\'%s)', $this->name, $this->alias ? ', \''.$dbParser->escape($this->alias) .'\'': '');
|
return sprintf('new SelectExpression(\'%s\'%s)', $this->name, $this->alias ? ', \''.$dbParser->escape($this->alias) .'\'': '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file SelectColumnTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/column/SelectColumnTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* SelectColumnTag class
|
* SelectColumnTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class SelectColumnsTag {
|
class SelectColumnsTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Column list
|
* Column list
|
||||||
* @var array value is SelectColumnTag object
|
* @var array value is SelectColumnTag object
|
||||||
|
|
@ -18,7 +19,8 @@
|
||||||
* @param Xml_Node_ $xml_columns
|
* @param Xml_Node_ $xml_columns
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function SelectColumnsTag($xml_columns_tag){
|
function SelectColumnsTag($xml_columns_tag)
|
||||||
|
{
|
||||||
if (!$xml_columns_tag)
|
if (!$xml_columns_tag)
|
||||||
$xml_columns_tag = new Xml_Node_();
|
$xml_columns_tag = new Xml_Node_();
|
||||||
|
|
||||||
|
|
@ -27,25 +29,29 @@
|
||||||
|
|
||||||
$this->columns = array();
|
$this->columns = array();
|
||||||
|
|
||||||
if(!$xml_columns) {
|
if(!$xml_columns)
|
||||||
|
{
|
||||||
$this->columns[] = new SelectColumnTag("*");
|
$this->columns[] = new SelectColumnTag("*");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
|
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
|
||||||
|
|
||||||
foreach($xml_columns as $column){
|
foreach($xml_columns as $column)
|
||||||
|
{
|
||||||
$this->columns[] = new SelectColumnTag($column);
|
$this->columns[] = new SelectColumnTag($column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$xml_queries) {
|
if(!$xml_queries)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_array($xml_queries)) $xml_queries = array($xml_queries);
|
if(!is_array($xml_queries)) $xml_queries = array($xml_queries);
|
||||||
|
|
||||||
foreach($xml_queries as $column){
|
foreach($xml_queries as $column)
|
||||||
|
{
|
||||||
$this->columns[] = new QueryTag($column, true);
|
$this->columns[] = new QueryTag($column, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -54,9 +60,11 @@
|
||||||
* SelectColumnTag object to string
|
* SelectColumnTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$output_columns = 'array(' . PHP_EOL;
|
$output_columns = 'array(' . PHP_EOL;
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column)
|
||||||
|
{
|
||||||
if(is_a($column, 'QueryTag'))
|
if(is_a($column, 'QueryTag'))
|
||||||
$output_columns .= $column->toString() . PHP_EOL . ',';
|
$output_columns .= $column->toString() . PHP_EOL . ',';
|
||||||
else
|
else
|
||||||
|
|
@ -71,13 +79,16 @@
|
||||||
* Return argument list
|
* Return argument list
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column)
|
||||||
|
{
|
||||||
if(is_a($column, 'QueryTag'))
|
if(is_a($column, 'QueryTag'))
|
||||||
$arguments = array_merge($arguments, $column->getArguments());
|
$arguments = array_merge($arguments, $column->getArguments());
|
||||||
}
|
}
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file SelectColumnsTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/column/SelectColumnsTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* UpdateColumnTag
|
* UpdateColumnTag
|
||||||
* Models the <column> tag inside an XML Query file whose action is 'update'
|
* Models the <column> tag inside an XML Query file whose action is 'update'
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class UpdateColumnTag extends ColumnTag {
|
class UpdateColumnTag extends ColumnTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* argument
|
* argument
|
||||||
* @var QueryArgument object
|
* @var QueryArgument object
|
||||||
|
|
@ -24,50 +25,59 @@
|
||||||
* @param object $column
|
* @param object $column
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function UpdateColumnTag($column) {
|
function UpdateColumnTag($column)
|
||||||
|
{
|
||||||
parent::ColumnTag($column->attrs->name);
|
parent::ColumnTag($column->attrs->name);
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$this->name = $dbParser->parseColumnName($this->name);
|
$this->name = $dbParser->parseColumnName($this->name);
|
||||||
if($column->attrs->var)
|
if($column->attrs->var)
|
||||||
$this->argument = new QueryArgument($column);
|
$this->argument = new QueryArgument($column);
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if(strpos($column->attrs->default, '.') !== false)
|
if(strpos($column->attrs->default, '.') !== false)
|
||||||
$this->default_value = "'" . $dbParser->parseColumnName($column->attrs->default) . "'";
|
$this->default_value = "'" . $dbParser->parseColumnName($column->attrs->default) . "'";
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$default_value = new DefaultValue($this->name, $column->attrs->default);
|
$default_value = new DefaultValue($this->name, $column->attrs->default);
|
||||||
if($default_value->isOperation())
|
if($default_value->isOperation())
|
||||||
$this->argument = new QueryArgument($column, true);
|
$this->argument = new QueryArgument($column, true);
|
||||||
//else $this->default_value = $dbParser->parseColumnName($column->attrs->default);
|
//else $this->default_value = $dbParser->parseColumnName($column->attrs->default);
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$this->default_value = $default_value->toString();
|
$this->default_value = $default_value->toString();
|
||||||
if($default_value->isStringFromFunction()){
|
if($default_value->isStringFromFunction())
|
||||||
|
{
|
||||||
$this->default_value = '"\'".' . $this->default_value . '."\'"';
|
$this->default_value = '"\'".' . $this->default_value . '."\'"';
|
||||||
}
|
}
|
||||||
if($default_value->isString()){
|
if($default_value->isString())
|
||||||
|
{
|
||||||
$this->default_value = '"' . $this->default_value . '"';
|
$this->default_value = '"' . $this->default_value . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpressionString(){
|
function getExpressionString()
|
||||||
|
{
|
||||||
if($this->argument)
|
if($this->argument)
|
||||||
|
{
|
||||||
return sprintf('new UpdateExpression(\'%s\', ${\'%s_argument\'})'
|
return sprintf('new UpdateExpression(\'%s\', ${\'%s_argument\'})'
|
||||||
, $this->name
|
, $this->name
|
||||||
, $this->argument->argument_name);
|
, $this->argument->argument_name);
|
||||||
else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return sprintf('new UpdateExpressionWithoutArgument(\'%s\', %s)'
|
return sprintf('new UpdateExpressionWithoutArgument(\'%s\', %s)'
|
||||||
, $this->name
|
, $this->name
|
||||||
, $this->default_value);
|
, $this->default_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument(){
|
function getArgument()
|
||||||
|
{
|
||||||
return $this->argument;
|
return $this->argument;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file UpdateColumnTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/column/UpdateColumnTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* UpdateColumnsTag
|
* UpdateColumnsTag
|
||||||
* Models the <column> tag inside an XML Query file whose action is 'update'
|
* Models the <column> tag inside an XML Query file whose action is 'update'
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/column
|
* @package /classes/xml/xmlquery/tags/column
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class UpdateColumnsTag{
|
class UpdateColumnsTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Column list
|
* Column list
|
||||||
* @var array value is UpdateColumnTag object
|
* @var array value is UpdateColumnTag object
|
||||||
|
|
@ -19,12 +20,14 @@
|
||||||
* @param array|string $xml_columns
|
* @param array|string $xml_columns
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function UpdateColumnsTag($xml_columns) {
|
function UpdateColumnsTag($xml_columns)
|
||||||
|
{
|
||||||
$this->columns = array();
|
$this->columns = array();
|
||||||
|
|
||||||
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
|
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
|
||||||
|
|
||||||
foreach($xml_columns as $column){
|
foreach($xml_columns as $column)
|
||||||
|
{
|
||||||
if($column->name === 'query') $this->columns[] = new QueryTag($column, true);
|
if($column->name === 'query') $this->columns[] = new QueryTag($column, true);
|
||||||
else $this->columns[] = new UpdateColumnTag($column);
|
else $this->columns[] = new UpdateColumnTag($column);
|
||||||
}
|
}
|
||||||
|
|
@ -34,9 +37,11 @@
|
||||||
* UpdateColumnTag object to string
|
* UpdateColumnTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$output_columns = 'array(' . PHP_EOL;
|
$output_columns = 'array(' . PHP_EOL;
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column)
|
||||||
|
{
|
||||||
$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
|
$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
|
||||||
}
|
}
|
||||||
$output_columns = substr($output_columns, 0, -1);
|
$output_columns = substr($output_columns, 0, -1);
|
||||||
|
|
@ -48,14 +53,15 @@
|
||||||
* Return argument list
|
* Return argument list
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column)
|
||||||
|
{
|
||||||
$arguments[] = $column->getArgument();
|
$arguments[] = $column->getArgument();
|
||||||
}
|
}
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
/* End of file UpdateColumnsTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/column/UpdateColumnsTag.class.php */
|
||||||
?>
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ConditionGroupTag class
|
* ConditionGroupTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/condition
|
* @package /classes/xml/xmlquery/tags/condition
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class ConditionGroupTag {
|
class ConditionGroupTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* condition list
|
* condition list
|
||||||
* @var string|array value is ConditionTag object
|
* @var string|array value is ConditionTag object
|
||||||
|
|
@ -24,18 +25,21 @@
|
||||||
* @param string $pipe
|
* @param string $pipe
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ConditionGroupTag($conditions, $pipe = ""){
|
function ConditionGroupTag($conditions, $pipe = "")
|
||||||
|
{
|
||||||
$this->pipe = $pipe;
|
$this->pipe = $pipe;
|
||||||
|
|
||||||
if(!is_array($conditions)) $conditions = array($conditions);
|
if(!is_array($conditions)) $conditions = array($conditions);
|
||||||
|
|
||||||
foreach($conditions as $condition){
|
foreach($conditions as $condition)
|
||||||
|
{
|
||||||
//if($condition->node_name === 'query') $this->conditions[] = new QueryTag($condition, true);
|
//if($condition->node_name === 'query') $this->conditions[] = new QueryTag($condition, true);
|
||||||
$this->conditions[] = new ConditionTag($condition);
|
$this->conditions[] = new ConditionTag($condition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConditions(){
|
function getConditions()
|
||||||
|
{
|
||||||
return $this->conditions;
|
return $this->conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,9 +47,11 @@
|
||||||
* ConditionTag object to string
|
* ConditionTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getConditionGroupString(){
|
function getConditionGroupString()
|
||||||
|
{
|
||||||
$conditions_string = 'array('.PHP_EOL;
|
$conditions_string = 'array('.PHP_EOL;
|
||||||
foreach($this->conditions as $condition){
|
foreach($this->conditions as $condition)
|
||||||
|
{
|
||||||
$conditions_string .= $condition->getConditionString() . PHP_EOL . ',';
|
$conditions_string .= $condition->getConditionString() . PHP_EOL . ',';
|
||||||
}
|
}
|
||||||
$conditions_string = substr($conditions_string, 0, -2);//remove ','
|
$conditions_string = substr($conditions_string, 0, -2);//remove ','
|
||||||
|
|
@ -54,13 +60,15 @@
|
||||||
return sprintf("new ConditionGroup(%s%s)", $conditions_string, $this->pipe ? ',\''.$this->pipe . '\'': '');
|
return sprintf("new ConditionGroup(%s%s)", $conditions_string, $this->pipe ? ',\''.$this->pipe . '\'': '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->conditions as $condition){
|
foreach($this->conditions as $condition)
|
||||||
|
{
|
||||||
$arguments = array_merge($arguments, $condition->getArguments());
|
$arguments = array_merge($arguments, $condition->getArguments());
|
||||||
}
|
}
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
/* End of file ConditionGroupTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/condition/ConditionGroupTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ConditionTag
|
* ConditionTag
|
||||||
* Models the <condition> tag inside an XML Query file. Base class.
|
* Models the <condition> tag inside an XML Query file. Base class.
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/condition
|
* @package /classes/xml/xmlquery/tags/condition
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class ConditionTag {
|
class ConditionTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* operation for example 'in', 'between', 'not in'...
|
* operation for example 'in', 'between', 'not in'...
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -49,7 +50,8 @@
|
||||||
* @param object $condition
|
* @param object $condition
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ConditionTag($condition){
|
function ConditionTag($condition)
|
||||||
|
{
|
||||||
$this->operation = $condition->attrs->operation;
|
$this->operation = $condition->attrs->operation;
|
||||||
$this->pipe = $condition->attrs->pipe;
|
$this->pipe = $condition->attrs->pipe;
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
|
|
@ -113,11 +115,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPipe($pipe){
|
function setPipe($pipe)
|
||||||
|
{
|
||||||
$this->pipe = $pipe;
|
$this->pipe = $pipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
if($this->query)
|
if($this->query)
|
||||||
$arguments = array_merge($arguments, $this->query->getArguments());
|
$arguments = array_merge($arguments, $this->query->getArguments());
|
||||||
|
|
@ -126,8 +130,10 @@
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConditionString(){
|
function getConditionString()
|
||||||
if($this->query){
|
{
|
||||||
|
if($this->query)
|
||||||
|
{
|
||||||
return sprintf("new ConditionSubquery('%s',%s,%s%s)"
|
return sprintf("new ConditionSubquery('%s',%s,%s%s)"
|
||||||
, $this->column_name
|
, $this->column_name
|
||||||
, $this->default_column
|
, $this->default_column
|
||||||
|
|
@ -135,7 +141,8 @@
|
||||||
, $this->pipe ? ", '" . $this->pipe . "'" : ''
|
, $this->pipe ? ", '" . $this->pipe . "'" : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if(isset($this->default_column)){
|
else if(isset($this->default_column))
|
||||||
|
{
|
||||||
return sprintf("new ConditionWithoutArgument('%s',%s,%s%s)"
|
return sprintf("new ConditionWithoutArgument('%s',%s,%s%s)"
|
||||||
, $this->column_name
|
, $this->column_name
|
||||||
, $this->default_column
|
, $this->default_column
|
||||||
|
|
@ -143,7 +150,8 @@
|
||||||
, $this->pipe ? ", '" . $this->pipe . "'" : ''
|
, $this->pipe ? ", '" . $this->pipe . "'" : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
return sprintf("new ConditionWithArgument('%s',%s,%s%s)"
|
return sprintf("new ConditionWithArgument('%s',%s,%s%s)"
|
||||||
, $this->column_name
|
, $this->column_name
|
||||||
, '$' . $this->argument_name . '_argument'
|
, '$' . $this->argument_name . '_argument'
|
||||||
|
|
@ -152,5 +160,6 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file ConditionTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/condition/ConditionTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* ConditionsTag class
|
* ConditionsTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/condition
|
* @package /classes/xml/xmlquery/tags/condition
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class ConditionsTag {
|
class ConditionsTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* ConditionGroupTag list
|
* ConditionGroupTag list
|
||||||
* @var array value is ConditionGroupTag object
|
* @var array value is ConditionGroupTag object
|
||||||
|
|
@ -18,28 +19,33 @@
|
||||||
* @param object $xml_conditions
|
* @param object $xml_conditions
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function ConditionsTag($xml_conditions){
|
function ConditionsTag($xml_conditions)
|
||||||
|
{
|
||||||
$this->condition_groups = array();
|
$this->condition_groups = array();
|
||||||
if (!$xml_conditions)
|
if(!$xml_conditions)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$xml_condition_list = array();
|
$xml_condition_list = array();
|
||||||
if($xml_conditions->condition)
|
if($xml_conditions->condition)
|
||||||
$xml_condition_list = $xml_conditions->condition;
|
$xml_condition_list = $xml_conditions->condition;
|
||||||
|
|
||||||
if($xml_conditions->query){
|
if($xml_conditions->query)
|
||||||
|
{
|
||||||
if(!is_array($xml_condition_list)) $xml_condition_list = array($xml_condition_list);
|
if(!is_array($xml_condition_list)) $xml_condition_list = array($xml_condition_list);
|
||||||
if(!is_array($xml_conditions->query)) $xml_conditions->query = array($xml_conditions->query);
|
if(!is_array($xml_conditions->query)) $xml_conditions->query = array($xml_conditions->query);
|
||||||
$xml_condition_list = array_merge($xml_condition_list, $xml_conditions->query);
|
$xml_condition_list = array_merge($xml_condition_list, $xml_conditions->query);
|
||||||
}
|
}
|
||||||
if($xml_condition_list){
|
if($xml_condition_list)
|
||||||
|
{
|
||||||
$this->condition_groups[] = new ConditionGroupTag($xml_condition_list);
|
$this->condition_groups[] = new ConditionGroupTag($xml_condition_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
$xml_groups = $xml_conditions->group;
|
$xml_groups = $xml_conditions->group;
|
||||||
if($xml_groups){
|
if($xml_groups)
|
||||||
|
{
|
||||||
if(!is_array($xml_groups)) $xml_groups = array($xml_groups);
|
if(!is_array($xml_groups)) $xml_groups = array($xml_groups);
|
||||||
foreach($xml_groups as $group){
|
foreach($xml_groups as $group)
|
||||||
|
{
|
||||||
$this->condition_groups[] = new ConditionGroupTag($group->condition, $group->attrs->pipe);
|
$this->condition_groups[] = new ConditionGroupTag($group->condition, $group->attrs->pipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -49,9 +55,11 @@
|
||||||
* ConditionGroupTag object to string
|
* ConditionGroupTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$output_conditions = 'array(' . PHP_EOL;
|
$output_conditions = 'array(' . PHP_EOL;
|
||||||
foreach($this->condition_groups as $condition){
|
foreach($this->condition_groups as $condition)
|
||||||
|
{
|
||||||
$output_conditions .= $condition->getConditionGroupString() . PHP_EOL . ',';
|
$output_conditions .= $condition->getConditionGroupString() . PHP_EOL . ',';
|
||||||
}
|
}
|
||||||
$output_conditions = substr($output_conditions, 0, -1);
|
$output_conditions = substr($output_conditions, 0, -1);
|
||||||
|
|
@ -59,12 +67,15 @@
|
||||||
return $output_conditions;
|
return $output_conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->condition_groups as $condition){
|
foreach($this->condition_groups as $condition)
|
||||||
|
{
|
||||||
$arguments = array_merge($arguments, $condition->getArguments());
|
$arguments = array_merge($arguments, $condition->getArguments());
|
||||||
}
|
}
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file ConditionsTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/condition/ConditionsTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* JoinConditionsTag class
|
* JoinConditionsTag class
|
||||||
*
|
*
|
||||||
* @author Corina
|
* @author Corina
|
||||||
* @package /classes/xml/xmlquery/tags/condition
|
* @package /classes/xml/xmlquery/tags/condition
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class JoinConditionsTag extends ConditionsTag {
|
class JoinConditionsTag extends ConditionsTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
* @param object $xml_conditions
|
* @param object $xml_conditions
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function JoinConditionsTag($xml_conditions){
|
function JoinConditionsTag($xml_conditions)
|
||||||
|
{
|
||||||
parent::ConditionsTag($xml_conditions);
|
parent::ConditionsTag($xml_conditions);
|
||||||
$this->condition_groups[0]->conditions[0]->setPipe("");
|
$this->condition_groups[0]->conditions[0]->setPipe("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file JoinConditionsTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/condition/JoinConditionsTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* GroupsTag class
|
* GroupsTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/group
|
* @package /classes/xml/xmlquery/tags/group
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class GroupsTag {
|
class GroupsTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* column list
|
* column list
|
||||||
* @var array
|
* @var array
|
||||||
|
|
@ -18,14 +19,17 @@
|
||||||
* @param array|string $xml_groups
|
* @param array|string $xml_groups
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function GroupsTag($xml_groups){
|
function GroupsTag($xml_groups)
|
||||||
|
{
|
||||||
$this->groups = array();
|
$this->groups = array();
|
||||||
|
|
||||||
if($xml_groups) {
|
if($xml_groups)
|
||||||
|
{
|
||||||
if(!is_array($xml_groups)) $xml_groups = array($xml_groups);
|
if(!is_array($xml_groups)) $xml_groups = array($xml_groups);
|
||||||
|
|
||||||
$dbParser = &DB::getParser();
|
$dbParser = &DB::getParser();
|
||||||
for($i=0;$i<count($xml_groups);$i++) {
|
for($i=0;$i<count($xml_groups);$i++)
|
||||||
|
{
|
||||||
$group = $xml_groups[$i];
|
$group = $xml_groups[$i];
|
||||||
$column = trim($group->attrs->column);
|
$column = trim($group->attrs->column);
|
||||||
if(!$column) continue;
|
if(!$column) continue;
|
||||||
|
|
@ -36,15 +40,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$output = 'array(' . PHP_EOL;
|
$output = 'array(' . PHP_EOL;
|
||||||
foreach($this->groups as $group){
|
foreach($this->groups as $group)
|
||||||
|
{
|
||||||
$output .= "'" . $group . "' ,";
|
$output .= "'" . $group . "' ,";
|
||||||
}
|
}
|
||||||
$output = substr($output, 0, -1);
|
$output = substr($output, 0, -1);
|
||||||
$output .= ')';
|
$output .= ')';
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file GroupsTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/group/GroupsTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* IndexTag class
|
* IndexTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/navigation
|
* @package /classes/xml/xmlquery/tags/navigation
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class IndexTag {
|
class IndexTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* argument name
|
* argument name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -38,7 +39,8 @@
|
||||||
* @param object $index
|
* @param object $index
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function IndexTag($index){
|
function IndexTag($index)
|
||||||
|
{
|
||||||
$this->argument_name = $index->attrs->var;
|
$this->argument_name = $index->attrs->var;
|
||||||
|
|
||||||
// Sort index - column by which to sort
|
// Sort index - column by which to sort
|
||||||
|
|
@ -50,7 +52,8 @@
|
||||||
// Sort order - asc / desc
|
// Sort order - asc / desc
|
||||||
$this->sort_order = $index->attrs->order;
|
$this->sort_order = $index->attrs->order;
|
||||||
$sortList = array('asc'=>1, 'desc'=>1);
|
$sortList = array('asc'=>1, 'desc'=>1);
|
||||||
if(!isset($sortList[$this->sort_order])){
|
if(!isset($sortList[$this->sort_order]))
|
||||||
|
{
|
||||||
$arg = new Xml_Node_();
|
$arg = new Xml_Node_();
|
||||||
$arg->attrs = new Xml_Node_();
|
$arg->attrs = new Xml_Node_();
|
||||||
$arg->attrs->var = $this->sort_order;
|
$arg->attrs->var = $this->sort_order;
|
||||||
|
|
@ -61,17 +64,19 @@
|
||||||
else $this->sort_order = '"'.$this->sort_order.'"';
|
else $this->sort_order = '"'.$this->sort_order.'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
return sprintf('new OrderByColumn(${\'%s_argument\'}, %s)', $this->argument->getArgumentName(), $this->sort_order);
|
return sprintf('new OrderByColumn(${\'%s_argument\'}, %s)', $this->argument->getArgumentName(), $this->sort_order);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
$arguments[] = $this->argument;
|
$arguments[] = $this->argument;
|
||||||
if($this->sort_order_argument)
|
if($this->sort_order_argument)
|
||||||
$arguments[] = $this->sort_order_argument;
|
$arguments[] = $this->sort_order_argument;
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file IndexTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/navigation/IndexTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* LimitTag class
|
* LimitTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/navigation
|
* @package /classes/xml/xmlquery/tags/navigation
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class LimitTag {
|
class LimitTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Value is relate to limit query
|
* Value is relate to limit query
|
||||||
* @var array
|
* @var array
|
||||||
|
|
@ -33,8 +34,10 @@
|
||||||
* @param object $index
|
* @param object $index
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function LimitTag($index){
|
function LimitTag($index)
|
||||||
if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs){
|
{
|
||||||
|
if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs)
|
||||||
|
{
|
||||||
$this->page = new QueryArgument($index->page);
|
$this->page = new QueryArgument($index->page);
|
||||||
$this->page_count = new QueryArgument($index->page_count);
|
$this->page_count = new QueryArgument($index->page_count);
|
||||||
$this->arguments[] = $this->page;
|
$this->arguments[] = $this->page;
|
||||||
|
|
@ -45,13 +48,16 @@
|
||||||
$this->arguments[] = $this->list_count;
|
$this->arguments[] = $this->list_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
if ($this->page)return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
|
{
|
||||||
|
if($this->page)return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
|
||||||
else return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName());
|
else return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
return $this->arguments;
|
return $this->arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file LimitTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/navigation/LimitTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* NavigationTag class
|
* NavigationTag class
|
||||||
*
|
*
|
||||||
* @author Arnia Software
|
* @author Arnia Software
|
||||||
* @package /classes/xml/xmlquery/tags/navigation
|
* @package /classes/xml/xmlquery/tags/navigation
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class NavigationTag {
|
class NavigationTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Order
|
* Order
|
||||||
* @var array
|
* @var array
|
||||||
|
|
@ -38,26 +39,30 @@
|
||||||
* @param object $xml_navigation
|
* @param object $xml_navigation
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function NavigationTag($xml_navigation){
|
function NavigationTag($xml_navigation)
|
||||||
|
{
|
||||||
$this->order = array();
|
$this->order = array();
|
||||||
if($xml_navigation) {
|
if($xml_navigation)
|
||||||
|
{
|
||||||
$order = $xml_navigation->index;
|
$order = $xml_navigation->index;
|
||||||
if($order) {
|
if($order)
|
||||||
|
{
|
||||||
if(!is_array($order)) $order = array($order);
|
if(!is_array($order)) $order = array($order);
|
||||||
foreach($order as $order_info) {
|
foreach($order as $order_info)
|
||||||
|
{
|
||||||
$this->order[] = new IndexTag($order_info);
|
$this->order[] = new IndexTag($order_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($xml_navigation->page && $xml_navigation->page->attrs || $xml_navigation->list_count && $xml_navigation->list_count->attrs)
|
if($xml_navigation->page && $xml_navigation->page->attrs || $xml_navigation->list_count && $xml_navigation->list_count->attrs)
|
||||||
$this->limit = new LimitTag($xml_navigation);
|
$this->limit = new LimitTag($xml_navigation);
|
||||||
|
|
||||||
if ($xml_navigation->list_count)
|
if($xml_navigation->list_count)
|
||||||
$this->list_count = $xml_navigation->list_count->attrs;
|
$this->list_count = $xml_navigation->list_count->attrs;
|
||||||
|
|
||||||
if ($xml_navigation->page_count)
|
if($xml_navigation->page_count)
|
||||||
$this->page_count = $xml_navigation->page_count->attrs;
|
$this->page_count = $xml_navigation->page_count->attrs;
|
||||||
|
|
||||||
if ($xml_navigation->page)
|
if($xml_navigation->page)
|
||||||
$this->page = $xml_navigation->page->attrs;
|
$this->page = $xml_navigation->page->attrs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -67,9 +72,11 @@
|
||||||
* NavigationTag object to string
|
* NavigationTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getOrderByString(){
|
function getOrderByString()
|
||||||
|
{
|
||||||
$output = 'array(' . PHP_EOL;
|
$output = 'array(' . PHP_EOL;
|
||||||
foreach($this->order as $order){
|
foreach($this->order as $order)
|
||||||
|
{
|
||||||
$output .= $order->toString() . PHP_EOL . ',';
|
$output .= $order->toString() . PHP_EOL . ',';
|
||||||
}
|
}
|
||||||
$output = substr($output, 0, -1);
|
$output = substr($output, 0, -1);
|
||||||
|
|
@ -81,19 +88,22 @@
|
||||||
* LimitTag object to string
|
* LimitTag object to string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getLimitString(){
|
function getLimitString()
|
||||||
if ($this->limit) return $this->limit->toString();
|
{
|
||||||
|
if($this->limit) return $this->limit->toString();
|
||||||
else return "";
|
else return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->order as $order){
|
foreach($this->order as $order)
|
||||||
|
{
|
||||||
$arguments = array_merge($order->getArguments(), $arguments);
|
$arguments = array_merge($order->getArguments(), $arguments);
|
||||||
}
|
}
|
||||||
if($this->limit) $arguments = array_merge($this->limit->getArguments(), $arguments);
|
if($this->limit) $arguments = array_merge($this->limit->getArguments(), $arguments);
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file NavigationTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/navigation/NavigationTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/query
|
* @package /classes/xml/xmlquery/tags/query
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class QueryTag {
|
class QueryTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Action for example, 'select', 'insert', 'delete'...
|
* Action for example, 'select', 'insert', 'delete'...
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -99,15 +100,17 @@ class QueryTag {
|
||||||
* @param bool $isSubQuery
|
* @param bool $isSubQuery
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function QueryTag($query, $isSubQuery = false) {
|
function QueryTag($query, $isSubQuery = false)
|
||||||
|
{
|
||||||
$this->action = $query->attrs->action;
|
$this->action = $query->attrs->action;
|
||||||
$this->query_id = $query->attrs->id;
|
$this->query_id = $query->attrs->id;
|
||||||
$this->priority = $query->attrs->priority;
|
$this->priority = $query->attrs->priority;
|
||||||
$this->query = $query;
|
$this->query = $query;
|
||||||
$this->isSubQuery = $isSubQuery;
|
$this->isSubQuery = $isSubQuery;
|
||||||
if ($this->isSubQuery)
|
if($this->isSubQuery)
|
||||||
$this->action = 'select';
|
$this->action = 'select';
|
||||||
if ($query->attrs->alias) {
|
if($query->attrs->alias)
|
||||||
|
{
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$this->alias = $dbParser->escape($query->attrs->alias);
|
$this->alias = $dbParser->escape($query->attrs->alias);
|
||||||
}
|
}
|
||||||
|
|
@ -121,34 +124,41 @@ class QueryTag {
|
||||||
$this->getGroups();
|
$this->getGroups();
|
||||||
$this->getNavigation();
|
$this->getNavigation();
|
||||||
|
|
||||||
|
|
||||||
$this->getPrebuff();
|
$this->getPrebuff();
|
||||||
$this->getBuff();
|
$this->getBuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueryId() {
|
function getQueryId()
|
||||||
|
{
|
||||||
return $this->query->attrs->query_id ? $this->query->attrs->query_id : $this->query->attrs->id;
|
return $this->query->attrs->query_id ? $this->query->attrs->query_id : $this->query->attrs->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPriority() {
|
function getPriority()
|
||||||
|
{
|
||||||
return $this->query->attrs->priority;
|
return $this->query->attrs->priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAction() {
|
function getAction()
|
||||||
|
{
|
||||||
return $this->query->attrs->action;
|
return $this->query->attrs->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTableColumnTypes($tables) {
|
function setTableColumnTypes($tables)
|
||||||
|
{
|
||||||
$query_id = $this->getQueryId();
|
$query_id = $this->getQueryId();
|
||||||
if (!isset($this->column_type[$query_id])) {
|
if(!isset($this->column_type[$query_id]))
|
||||||
|
{
|
||||||
$table_tags = $tables->getTables();
|
$table_tags = $tables->getTables();
|
||||||
$column_type = array();
|
$column_type = array();
|
||||||
foreach ($table_tags as $table_tag) {
|
foreach ($table_tags as $table_tag)
|
||||||
if (is_a($table_tag, 'TableTag')) {
|
{
|
||||||
|
if(is_a($table_tag, 'TableTag'))
|
||||||
|
{
|
||||||
$table_name = $table_tag->getTableName();
|
$table_name = $table_tag->getTableName();
|
||||||
$table_alias = $table_tag->getTableAlias();
|
$table_alias = $table_tag->getTableAlias();
|
||||||
$tag_column_type = QueryParser::getTableInfo($query_id, $table_name);
|
$tag_column_type = QueryParser::getTableInfo($query_id, $table_name);
|
||||||
|
|
@ -159,28 +169,40 @@ class QueryTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColumns(){
|
function getColumns()
|
||||||
if($this->action == 'select'){
|
{
|
||||||
|
if($this->action == 'select')
|
||||||
|
{
|
||||||
return $this->columns = new SelectColumnsTag($this->query->columns);
|
return $this->columns = new SelectColumnsTag($this->query->columns);
|
||||||
}else if($this->action == 'insert' || $this->action == 'insert-select'){
|
}
|
||||||
|
else if($this->action == 'insert' || $this->action == 'insert-select')
|
||||||
|
{
|
||||||
return $this->columns = new InsertColumnsTag($this->query->columns->column);
|
return $this->columns = new InsertColumnsTag($this->query->columns->column);
|
||||||
}else if($this->action == 'update') {
|
}
|
||||||
|
else if($this->action == 'update')
|
||||||
|
{
|
||||||
return $this->columns = new UpdateColumnsTag($this->query->columns->column);
|
return $this->columns = new UpdateColumnsTag($this->query->columns->column);
|
||||||
}else if($this->action == 'delete') {
|
}
|
||||||
|
else if($this->action == 'delete')
|
||||||
|
{
|
||||||
return $this->columns = null;
|
return $this->columns = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrebuff() {
|
function getPrebuff()
|
||||||
|
{
|
||||||
if($this->isSubQuery) return;
|
if($this->isSubQuery) return;
|
||||||
// TODO Check if this work with arguments in join clause
|
// TODO Check if this work with arguments in join clause
|
||||||
$arguments = $this->getArguments();
|
$arguments = $this->getArguments();
|
||||||
|
|
||||||
$prebuff = '';
|
$prebuff = '';
|
||||||
foreach ($arguments as $argument) {
|
foreach ($arguments as $argument)
|
||||||
if (isset($argument)) {
|
{
|
||||||
|
if(isset($argument))
|
||||||
|
{
|
||||||
$arg_name = $argument->getArgumentName();
|
$arg_name = $argument->getArgumentName();
|
||||||
if ($arg_name) {
|
if($arg_name)
|
||||||
|
{
|
||||||
unset($column_type);
|
unset($column_type);
|
||||||
$prebuff .= $argument->toString();
|
$prebuff .= $argument->toString();
|
||||||
|
|
||||||
|
|
@ -201,8 +223,8 @@ class QueryTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($column_type))
|
if (isset($column_type))
|
||||||
|
{
|
||||||
$prebuff .= sprintf('if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');' . "\n"
|
$prebuff .= sprintf('if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');' . "\n"
|
||||||
, $arg_name
|
, $arg_name
|
||||||
, $arg_name
|
, $arg_name
|
||||||
|
|
@ -210,14 +232,17 @@ class QueryTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$prebuff .= "\n";
|
$prebuff .= "\n";
|
||||||
|
|
||||||
return $this->preBuff = $prebuff;
|
return $this->preBuff = $prebuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBuff() {
|
function getBuff()
|
||||||
|
{
|
||||||
$buff = '';
|
$buff = '';
|
||||||
if ($this->isSubQuery) {
|
if($this->isSubQuery)
|
||||||
|
{
|
||||||
$buff = 'new Subquery(';
|
$buff = 'new Subquery(';
|
||||||
$buff .= "'" . $this->alias . '\', ';
|
$buff .= "'" . $this->alias . '\', ';
|
||||||
$buff .= ($this->columns ? $this->columns->toString() : 'null' ) . ', ' . PHP_EOL;
|
$buff .= ($this->columns ? $this->columns->toString() : 'null' ) . ', ' . PHP_EOL;
|
||||||
|
|
@ -239,7 +264,7 @@ class QueryTag {
|
||||||
$buff .= sprintf('$query->setAction("%s");%s', $this->action, "\n");
|
$buff .= sprintf('$query->setAction("%s");%s', $this->action, "\n");
|
||||||
$buff .= sprintf('$query->setPriority("%s");%s', $this->priority, "\n");
|
$buff .= sprintf('$query->setPriority("%s");%s', $this->priority, "\n");
|
||||||
$buff .= $this->preBuff;
|
$buff .= $this->preBuff;
|
||||||
if ($this->columns)
|
if($this->columns)
|
||||||
$buff .= '$query->setColumns(' . $this->columns->toString() . ');' . PHP_EOL;
|
$buff .= '$query->setColumns(' . $this->columns->toString() . ');' . PHP_EOL;
|
||||||
|
|
||||||
$buff .= '$query->setTables(' . $this->tables->toString() .');'.PHP_EOL;
|
$buff .= '$query->setTables(' . $this->tables->toString() .');'.PHP_EOL;
|
||||||
|
|
@ -254,53 +279,64 @@ class QueryTag {
|
||||||
return $this->buff;
|
return $this->buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTables() {
|
function getTables()
|
||||||
|
{
|
||||||
if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for)))
|
if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for)))
|
||||||
return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint);
|
return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint);
|
||||||
else
|
else
|
||||||
return $this->tables = new TablesTag($this->query->tables);
|
return $this->tables = new TablesTag($this->query->tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubquery(){
|
function getSubquery()
|
||||||
if($this->query->query){
|
{
|
||||||
|
if($this->query->query)
|
||||||
|
{
|
||||||
$this->subquery = new QueryTag($this->query->query, true);
|
$this->subquery = new QueryTag($this->query->query, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConditions(){
|
function getConditions()
|
||||||
|
{
|
||||||
return $this->conditions = new ConditionsTag($this->query->conditions);
|
return $this->conditions = new ConditionsTag($this->query->conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroups() {
|
function getGroups()
|
||||||
if ($this->query->groups)
|
{
|
||||||
|
if($this->query->groups)
|
||||||
return $this->groups = new GroupsTag($this->query->groups->group);
|
return $this->groups = new GroupsTag($this->query->groups->group);
|
||||||
else
|
else
|
||||||
return $this->groups = new GroupsTag(NULL);
|
return $this->groups = new GroupsTag(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNavigation() {
|
function getNavigation()
|
||||||
|
{
|
||||||
return $this->navigation = new NavigationTag($this->query->navigation);
|
return $this->navigation = new NavigationTag($this->query->navigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString() {
|
function toString()
|
||||||
|
{
|
||||||
return $this->buff;
|
return $this->buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableString() {
|
function getTableString()
|
||||||
|
{
|
||||||
return $this->buff;
|
return $this->buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConditionString() {
|
function getConditionString()
|
||||||
|
{
|
||||||
return $this->buff;
|
return $this->buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpressionString() {
|
function getExpressionString()
|
||||||
|
{
|
||||||
return $this->buff;
|
return $this->buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
if ($this->columns)
|
if($this->columns)
|
||||||
$arguments = array_merge($arguments, $this->columns->getArguments());
|
$arguments = array_merge($arguments, $this->columns->getArguments());
|
||||||
if($this->action =='insert-select')
|
if($this->action =='insert-select')
|
||||||
$arguments = array_merge($arguments, $this->subquery->getArguments());
|
$arguments = array_merge($arguments, $this->subquery->getArguments());
|
||||||
|
|
@ -309,7 +345,6 @@ class QueryTag {
|
||||||
$arguments = array_merge($arguments, $this->navigation->getArguments());
|
$arguments = array_merge($arguments, $this->navigation->getArguments());
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* End of file QueryTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/navigation/QueryTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
include 'TableTag.class.php';
|
||||||
|
/**
|
||||||
* HintTableTag
|
* HintTableTag
|
||||||
* Models the <table> tag inside an XML Query file and the corresponding <index_hint> tag
|
* Models the <table> tag inside an XML Query file and the corresponding <index_hint> tag
|
||||||
*
|
*
|
||||||
|
|
@ -7,7 +8,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/table
|
* @package /classes/xml/xmlquery/tags/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class HintTableTag extends TableTag {
|
class HintTableTag extends TableTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Action for example, 'select', 'insert', 'delete'...
|
* Action for example, 'select', 'insert', 'delete'...
|
||||||
* @var array
|
* @var array
|
||||||
|
|
@ -21,12 +23,14 @@
|
||||||
* @param array $index
|
* @param array $index
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function HintTableTag($table, $index){
|
function HintTableTag($table, $index)
|
||||||
|
{
|
||||||
parent::TableTag($table);
|
parent::TableTag($table);
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableString(){
|
function getTableString()
|
||||||
|
{
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$dbType = ucfirst(Context::getDBType());
|
$dbType = ucfirst(Context::getDBType());
|
||||||
|
|
||||||
|
|
@ -36,7 +40,8 @@
|
||||||
, $this->alias ? ', \'' . $dbParser->escape($this->alias) .'\'' : ', null'
|
, $this->alias ? ', \'' . $dbParser->escape($this->alias) .'\'' : ', null'
|
||||||
//, ', \'' . $dbParser->escape($this->index->name) .'\', \'' . $this->index->type .'\''
|
//, ', \'' . $dbParser->escape($this->index->name) .'\', \'' . $this->index->type .'\''
|
||||||
);
|
);
|
||||||
foreach($this->index as $indx){
|
foreach($this->index as $indx)
|
||||||
|
{
|
||||||
$result .= "new IndexHint(";
|
$result .= "new IndexHint(";
|
||||||
$result .= '\'' . $dbParser->escape($indx->name) .'\', \'' . $indx->type .'\'' . ') , ';
|
$result .= '\'' . $dbParser->escape($indx->name) .'\', \'' . $indx->type .'\'' . ') , ';
|
||||||
}
|
}
|
||||||
|
|
@ -45,10 +50,11 @@
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
if(!isset($this->conditionsTag)) return array();
|
if(!isset($this->conditionsTag)) return array();
|
||||||
return $this->conditionsTag->getArguments();
|
return $this->conditionsTag->getArguments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file HintTableTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/table/HintTableTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* TableTag
|
* TableTag
|
||||||
* Models the <table> tag inside an XML Query file
|
* Models the <table> tag inside an XML Query file
|
||||||
* @abstract
|
* @abstract
|
||||||
|
|
@ -18,7 +18,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/table
|
* @package /classes/xml/xmlquery/tags/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class TableTag {
|
class TableTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Unescaped name
|
* Unescaped name
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -57,7 +58,8 @@
|
||||||
* @param object $table XML <table> tag
|
* @param object $table XML <table> tag
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function TableTag($table){
|
function TableTag($table)
|
||||||
|
{
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
|
|
||||||
$this->unescaped_name = $table->attrs->name;
|
$this->unescaped_name = $table->attrs->name;
|
||||||
|
|
@ -74,18 +76,21 @@
|
||||||
$this->conditionsTag = new JoinConditionsTag($this->conditions);
|
$this->conditionsTag = new JoinConditionsTag($this->conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJoinTable(){
|
function isJoinTable()
|
||||||
|
{
|
||||||
$joinList = array('left join'=>1, 'left outer join'=>1, 'right join'=>1, 'right outer join'=>1);
|
$joinList = array('left join'=>1, 'left outer join'=>1, 'right join'=>1, 'right outer join'=>1);
|
||||||
if(isset($joinList[$this->join_type])
|
if(isset($joinList[$this->join_type])
|
||||||
&& count($this->conditions)) return true;
|
&& count($this->conditions)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableAlias(){
|
function getTableAlias()
|
||||||
|
{
|
||||||
return $this->alias;
|
return $this->alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableName(){
|
function getTableName()
|
||||||
|
{
|
||||||
return $this->unescaped_name;
|
return $this->unescaped_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,10 +100,12 @@
|
||||||
* a Table or a JoinTable object
|
* a Table or a JoinTable object
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getTableString(){
|
function getTableString()
|
||||||
|
{
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
|
|
||||||
if($this->isJoinTable()){
|
if($this->isJoinTable())
|
||||||
|
{
|
||||||
return sprintf('new JoinTable(\'%s\', \'%s\', "%s", %s)'
|
return sprintf('new JoinTable(\'%s\', \'%s\', "%s", %s)'
|
||||||
, $dbParser->escape($this->name)
|
, $dbParser->escape($this->name)
|
||||||
, $dbParser->escape($this->alias)
|
, $dbParser->escape($this->alias)
|
||||||
|
|
@ -109,10 +116,11 @@
|
||||||
, $this->alias ? ', \'' . $dbParser->escape($this->alias) .'\'' : '');
|
, $this->alias ? ', \'' . $dbParser->escape($this->alias) .'\'' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
if(!isset($this->conditionsTag)) return array();
|
if(!isset($this->conditionsTag)) return array();
|
||||||
return $this->conditionsTag->getArguments();
|
return $this->conditionsTag->getArguments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file TableTag.class.php */
|
||||||
?>
|
/* Location: ./classes/xml/xmlquery/tags/table/TableTag.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* TablesTag class
|
* TablesTag class
|
||||||
* Models the <tables> tag inside an XML Query file
|
* Models the <tables> tag inside an XML Query file
|
||||||
* @abstract
|
* @abstract
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
* @package /classes/xml/xmlquery/tags/table
|
* @package /classes/xml/xmlquery/tags/table
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
class TablesTag {
|
class TablesTag
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Table list
|
* Table list
|
||||||
* @var array
|
* @var array
|
||||||
|
|
@ -29,16 +30,19 @@
|
||||||
* @param object $xml_index_hints_tag
|
* @param object $xml_index_hints_tag
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function TablesTag($xml_tables_tag, $xml_index_hints_tag = NULL){
|
function TablesTag($xml_tables_tag, $xml_index_hints_tag = NULL)
|
||||||
|
{
|
||||||
$this->tables = array();
|
$this->tables = array();
|
||||||
|
|
||||||
$xml_tables = $xml_tables_tag->table;
|
$xml_tables = $xml_tables_tag->table;
|
||||||
if(!is_array($xml_tables)) $xml_tables = array($xml_tables);
|
if(!is_array($xml_tables)) $xml_tables = array($xml_tables);
|
||||||
|
|
||||||
if($xml_index_hints_tag){
|
if($xml_index_hints_tag)
|
||||||
|
{
|
||||||
$index_nodes = $xml_index_hints_tag->index;
|
$index_nodes = $xml_index_hints_tag->index;
|
||||||
if(!is_array($index_nodes)) $index_nodes = array($index_nodes);
|
if(!is_array($index_nodes)) $index_nodes = array($index_nodes);
|
||||||
foreach($index_nodes as $index_node) {
|
foreach($index_nodes as $index_node)
|
||||||
|
{
|
||||||
if(!isset($indexes[$index_node->attrs->table])) $indexes[$index_node->attrs->table] = array();
|
if(!isset($indexes[$index_node->attrs->table])) $indexes[$index_node->attrs->table] = array();
|
||||||
$count = count($indexes[$index_node->attrs->table]);
|
$count = count($indexes[$index_node->attrs->table]);
|
||||||
$indexes[$index_node->attrs->table][$count] = (object) NULL;
|
$indexes[$index_node->attrs->table][$count] = (object) NULL;
|
||||||
|
|
@ -47,11 +51,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($xml_tables as $tag){
|
foreach($xml_tables as $tag)
|
||||||
if($tag->attrs->query == 'true'){
|
{
|
||||||
|
if($tag->attrs->query == 'true')
|
||||||
|
{
|
||||||
$this->tables[] = new QueryTag($tag, true);
|
$this->tables[] = new QueryTag($tag, true);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if(isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
|
if(isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
|
||||||
$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
|
$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
|
||||||
else
|
else
|
||||||
|
|
@ -60,13 +67,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTables(){
|
function getTables()
|
||||||
|
{
|
||||||
return $this->tables;
|
return $this->tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString()
|
||||||
|
{
|
||||||
$output_tables = 'array(' . PHP_EOL;
|
$output_tables = 'array(' . PHP_EOL;
|
||||||
foreach($this->tables as $table){
|
foreach($this->tables as $table)
|
||||||
|
{
|
||||||
if(is_a($table, 'QueryTag'))
|
if(is_a($table, 'QueryTag'))
|
||||||
$output_tables .= $table->toString() . PHP_EOL . ',';
|
$output_tables .= $table->toString() . PHP_EOL . ',';
|
||||||
else
|
else
|
||||||
|
|
@ -77,11 +87,13 @@
|
||||||
return $output_tables;
|
return $output_tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArguments(){
|
function getArguments()
|
||||||
|
{
|
||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach($this->tables as $table)
|
foreach($this->tables as $table)
|
||||||
$arguments = array_merge($arguments, $table->getArguments());
|
$arguments = array_merge($arguments, $table->getArguments());
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
/* End of file TablesTag.class.php */
|
||||||
|
/* Location: ./classes/xml/xmlquery/tags/table/TablesTag.class.php */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue