Updated sql-parser library to udan11/sql-parser@5278427.
Signed-off-by: Dan Ungureanu <udan1107@gmail.com>
This commit is contained in:
parent
ecc60f3664
commit
2dfc29df4a
@ -818,9 +818,9 @@ class PMA_Table
|
||||
|
||||
/**
|
||||
* The destination where the table is moved or copied to.
|
||||
* @var SqlParser\Fragments\FieldFragment
|
||||
* @var SqlParser\Components\Expression
|
||||
*/
|
||||
$destination = new SqlParser\Fragments\FieldFragment(
|
||||
$destination = new SqlParser\Components\Expression(
|
||||
$target_db, $target_table, ''
|
||||
);
|
||||
|
||||
@ -850,7 +850,7 @@ class PMA_Table
|
||||
*/
|
||||
$statement = new SqlParser\Statements\DropStatement();
|
||||
|
||||
$statement->options = new SqlParser\Fragments\OptionsFragment(
|
||||
$statement->options = new SqlParser\Components\OptionsArray(
|
||||
array(
|
||||
PMA_Table::isView($target_db, $target_table) ?
|
||||
'VIEW' : 'TABLE',
|
||||
|
||||
@ -1,26 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Defines a fragment that is later extended to parse fragments or keywords.
|
||||
* Defines a component that is later extended to parse specialized components or
|
||||
* keywords.
|
||||
*
|
||||
* There is a small difference between *Fragment and *Keyword classes: usually,
|
||||
* *Fragment parsers can be reused in multiple situations and *Keyword parsers
|
||||
* count on the *Fragment classes to do their job.
|
||||
* There is a small difference between *Component and *Keyword classes: usually,
|
||||
* *Component parsers can be reused in multiple situations and *Keyword parsers
|
||||
* count on the *Component classes to do their job.
|
||||
*
|
||||
* @package SqlParser
|
||||
*/
|
||||
namespace SqlParser;
|
||||
|
||||
/**
|
||||
* A fragment (of a statement) is a part of a statement that is common to
|
||||
* A component (of a statement) is a part of a statement that is common to
|
||||
* multiple query types.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
abstract class Fragment
|
||||
abstract class Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -41,16 +42,16 @@ abstract class Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the string representation of a fragment of this type.
|
||||
* Builds the string representation of a component of this type.
|
||||
*
|
||||
* In other words, this function represents the inverse function of
|
||||
* `static::parse`.
|
||||
*
|
||||
* @param mixed $fragment The fragment to be built.
|
||||
* @param mixed $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
// This method should be abstract, but it can't be both static and
|
||||
// abstract.
|
||||
@ -4,11 +4,11 @@
|
||||
* Parses a reference to a field.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -16,13 +16,13 @@ use SqlParser\TokensList;
|
||||
/**
|
||||
* Parses a reference to a field.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class AlterFragment extends Fragment
|
||||
class AlterOperation extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -77,14 +77,14 @@ class AlterFragment extends Fragment
|
||||
/**
|
||||
* Options of this operation.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*/
|
||||
public $options;
|
||||
|
||||
/**
|
||||
* The altered field.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $field;
|
||||
|
||||
@ -100,11 +100,11 @@ class AlterFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return AlterFragment
|
||||
* @return AlterOperation
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new AlterFragment();
|
||||
$ret = new AlterOperation();
|
||||
|
||||
/**
|
||||
* Counts brackets.
|
||||
@ -148,10 +148,10 @@ class AlterFragment extends Fragment
|
||||
}
|
||||
|
||||
if ($state === 0) {
|
||||
$ret->options = OptionsFragment::parse($parser, $list, static::$OPTIONS);
|
||||
$ret->options = OptionsArray::parse($parser, $list, static::$OPTIONS);
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
$ret->field = FieldFragment::parse(
|
||||
$ret->field = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
array(
|
||||
@ -184,17 +184,17 @@ class AlterFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AlterFragment $fragment The fragment to be built.
|
||||
* @param AlterOperation $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$ret = OptionsFragment::build($fragment->options) . ' ';
|
||||
if (!empty($fragment->field)) {
|
||||
$ret .= FieldFragment::build($fragment->field) . ' ';
|
||||
$ret = OptionsArray::build($component->options) . ' ';
|
||||
if (!empty($component->field)) {
|
||||
$ret .= Expression::build($component->field) . ' ';
|
||||
}
|
||||
foreach ($fragment->unknown as $token) {
|
||||
foreach ($component->unknown as $token) {
|
||||
$ret .= $token->token;
|
||||
}
|
||||
return $ret;
|
||||
@ -4,11 +4,11 @@
|
||||
* `VALUES` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class ValuesKeyword extends Fragment
|
||||
class Array2d extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -37,13 +37,13 @@ class ValuesKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return ValuesKeyword
|
||||
* @return Array2d
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$expr = new ValuesKeyword();
|
||||
$expr = new Array2d();
|
||||
$value = '';
|
||||
|
||||
/**
|
||||
@ -102,7 +102,7 @@ class ValuesKeyword extends Fragment
|
||||
$expr->values[] = $value;
|
||||
$ret[] = $expr;
|
||||
$value = '';
|
||||
$expr = new ValuesKeyword();
|
||||
$expr = new Array2d();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
* Parses an array.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -16,13 +16,13 @@ use SqlParser\TokensList;
|
||||
/**
|
||||
* Parses an array.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class ArrayFragment extends Fragment
|
||||
class ArrayObj extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -56,11 +56,11 @@ class ArrayFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return ArrayFragment
|
||||
* @return ArrayObj
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new ArrayFragment();
|
||||
$ret = new ArrayObj();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -127,17 +127,17 @@ class ArrayFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayFragment $fragment The fragment to be built.
|
||||
* @param ArrayObj $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$values = array();
|
||||
if (!empty($fragment->raw)) {
|
||||
$values = $fragment->raw;
|
||||
if (!empty($component->raw)) {
|
||||
$values = $component->raw;
|
||||
} else {
|
||||
foreach ($fragment->values as $value) {
|
||||
foreach ($component->values as $value) {
|
||||
$values[] = $value;
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* `WHERE` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class WhereKeyword extends Fragment
|
||||
class Condition extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ class WhereKeyword extends Fragment
|
||||
public $identifiers = array();
|
||||
|
||||
/**
|
||||
* Whether this fragment is an operator.
|
||||
* Whether this component is an operator.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
@ -77,13 +77,13 @@ class WhereKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return WhereKeyword[]
|
||||
* @return Condition[]
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$expr = new WhereKeyword();
|
||||
$expr = new Condition();
|
||||
|
||||
/**
|
||||
* Counts brackets.
|
||||
@ -130,11 +130,11 @@ class WhereKeyword extends Fragment
|
||||
}
|
||||
|
||||
// Adding the operator.
|
||||
$expr = new WhereKeyword($token->value);
|
||||
$expr = new Condition($token->value);
|
||||
$expr->isOperator = true;
|
||||
$ret[] = $expr;
|
||||
|
||||
$expr = new WhereKeyword();
|
||||
$expr = new Condition();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -178,14 +178,14 @@ class WhereKeyword extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WhereKeyword[] $fragment The fragment to be built.
|
||||
* @param Condition[] $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($fragment as $f) {
|
||||
foreach ($component as $f) {
|
||||
$ret[] = $f->expr;
|
||||
}
|
||||
return implode(' ', $ret);
|
||||
@ -4,11 +4,11 @@
|
||||
* Parses a data type.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -16,13 +16,13 @@ use SqlParser\TokensList;
|
||||
/**
|
||||
* Parses a data type.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class DataTypeFragment extends Fragment
|
||||
class DataType extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -64,7 +64,7 @@ class DataTypeFragment extends Fragment
|
||||
/**
|
||||
* The options of this data type.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*/
|
||||
public $options;
|
||||
|
||||
@ -73,7 +73,7 @@ class DataTypeFragment extends Fragment
|
||||
*
|
||||
* @param string $name The name of this data type.
|
||||
* @param array $parameters The parameters (size or possible values).
|
||||
* @param OptionsFragment $options The options of this data type.
|
||||
* @param OptionsArray $options The options of this data type.
|
||||
*/
|
||||
public function __construct($name = null, array $parameters = array(),
|
||||
$options = null
|
||||
@ -88,11 +88,11 @@ class DataTypeFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return DataTypeFragment
|
||||
* @return DataType
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new DataTypeFragment();
|
||||
$ret = new DataType();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -127,12 +127,12 @@ class DataTypeFragment extends Fragment
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
|
||||
$parameters = ArrayFragment::parse($parser, $list);
|
||||
$parameters = ArrayObj::parse($parser, $list);
|
||||
++$list->idx;
|
||||
$ret->parameters = (($ret->name === 'ENUM') || ($ret->name === 'SET')) ?
|
||||
$parameters->raw : $parameters->values;
|
||||
}
|
||||
$ret->options = OptionsFragment::parse($parser, $list, static::$DATA_TYPE_OPTIONS);
|
||||
$ret->options = OptionsArray::parse($parser, $list, static::$DATA_TYPE_OPTIONS);
|
||||
++$list->idx;
|
||||
break;
|
||||
}
|
||||
@ -148,19 +148,19 @@ class DataTypeFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataTypeFragment $fragment The fragment to be built.
|
||||
* @param DataType $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$tmp = '';
|
||||
if (!empty($fragment->parameters)) {
|
||||
$tmp = '(' . implode(', ', $fragment->parameters) . ')';
|
||||
if (!empty($component->parameters)) {
|
||||
$tmp = '(' . implode(', ', $component->parameters) . ')';
|
||||
}
|
||||
return trim(
|
||||
$fragment->name . ' ' . $tmp . ' '
|
||||
. OptionsFragment::build($fragment->options)
|
||||
$component->name . ' ' . $tmp . ' '
|
||||
. OptionsArray::build($component->options)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -4,12 +4,12 @@
|
||||
* Parses a reference to a field.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Context;
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -17,13 +17,13 @@ use SqlParser\TokensList;
|
||||
/**
|
||||
* Parses a reference to a field.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class FieldFragment extends Fragment
|
||||
class Expression extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -79,10 +79,10 @@ class FieldFragment extends Fragment
|
||||
* Constructor.
|
||||
*
|
||||
* Syntax:
|
||||
* new FieldFragment('expr')
|
||||
* new FieldFragment('expr', 'alias')
|
||||
* new FieldFragment('database', 'table', 'column')
|
||||
* new FieldFragment('database', 'table', 'column', 'alias')
|
||||
* new Expression('expr')
|
||||
* new Expression('expr', 'alias')
|
||||
* new Expression('database', 'table', 'column')
|
||||
* new Expression('database', 'table', 'column', 'alias')
|
||||
*
|
||||
* If the database, table or column name is not required, pass an empty
|
||||
* string.
|
||||
@ -112,11 +112,11 @@ class FieldFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return FieldFragment
|
||||
* @return Expression
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new FieldFragment();
|
||||
$ret = new Expression();
|
||||
|
||||
/**
|
||||
* Whether current tokens make an expression or a table reference.
|
||||
@ -306,30 +306,30 @@ class FieldFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FieldFragment $fragment The fragment to be built.
|
||||
* @param Expression $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
if (!empty($fragment->expr)) {
|
||||
$ret = $fragment->expr;
|
||||
if (!empty($component->expr)) {
|
||||
$ret = $component->expr;
|
||||
} else {
|
||||
$fields = array();
|
||||
if (!empty($fragment->database)) {
|
||||
$fields[] = $fragment->database;
|
||||
if (!empty($component->database)) {
|
||||
$fields[] = $component->database;
|
||||
}
|
||||
if (!empty($fragment->table)) {
|
||||
$fields[] = $fragment->table;
|
||||
if (!empty($component->table)) {
|
||||
$fields[] = $component->table;
|
||||
}
|
||||
if (!empty($fragment->column)) {
|
||||
$fields[] = $fragment->column;
|
||||
if (!empty($component->column)) {
|
||||
$fields[] = $component->column;
|
||||
}
|
||||
$ret = implode('.', Context::escape($fields));
|
||||
}
|
||||
|
||||
if (!empty($fragment->alias)) {
|
||||
$ret .= ' AS ' . Context::escape($fragment->alias);
|
||||
if (!empty($component->alias)) {
|
||||
$ret .= ' AS ' . Context::escape($component->alias);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@ -4,11 +4,11 @@
|
||||
* Parses a a list of fields delimited by a single comma.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class FieldListFragment extends Fragment
|
||||
class ExpressionArray extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@ class FieldListFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return FieldFragment[]
|
||||
* @return Expression[]
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
@ -63,7 +63,7 @@ class FieldListFragment extends Fragment
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === ',')) {
|
||||
$ret[] = $expr;
|
||||
} else {
|
||||
$expr = FieldFragment::parse($parser, $list, $options);
|
||||
$expr = Expression::parse($parser, $list, $options);
|
||||
if ($expr === null) {
|
||||
break;
|
||||
}
|
||||
@ -81,14 +81,14 @@ class FieldListFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FieldFragment[] $fragment The fragment to be built.
|
||||
* @param Expression[] $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($fragment as $frag) {
|
||||
foreach ($component as $frag) {
|
||||
$ret[] = $frag::build($frag);
|
||||
}
|
||||
return implode($ret, ', ');
|
||||
@ -6,12 +6,12 @@
|
||||
* Used for parsing `CREATE TABLE` statement.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Context;
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -21,13 +21,13 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* Used for parsing `CREATE TABLE` statement.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class FieldDefFragment extends Fragment
|
||||
class FieldDefinition extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -66,28 +66,28 @@ class FieldDefFragment extends Fragment
|
||||
/**
|
||||
* The data type of thew new column.
|
||||
*
|
||||
* @var DataTypeFragment
|
||||
* @var DataType
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* The key.
|
||||
*
|
||||
* @var KeyFragment
|
||||
* @var Key
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* The table that is referenced.
|
||||
*
|
||||
* @var ReferencesKeyword
|
||||
* @var Reference
|
||||
*/
|
||||
public $references;
|
||||
|
||||
/**
|
||||
* The options of the new field fragment.
|
||||
* The options of this field.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*/
|
||||
public $options;
|
||||
|
||||
@ -95,19 +95,19 @@ class FieldDefFragment extends Fragment
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The name of the field.
|
||||
* @param OptionsFragment $options The options of this field.
|
||||
* @param DataTypeFragment|KeyFragment $type The data type of this field or the key.
|
||||
* @param OptionsArray $options The options of this field.
|
||||
* @param DataType|Key $type The data type of this field or the key.
|
||||
* @param bool $isConstraint Whether this field is a constraint or not.
|
||||
* @param ReferencesKeyword $references References.
|
||||
* @param Reference $references References.
|
||||
*/
|
||||
public function __construct($name = null, $options = null, $type = null,
|
||||
$isConstraint = false, $references = null
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->options = $options;
|
||||
if ($type instanceof DataTypeFragment) {
|
||||
if ($type instanceof DataType) {
|
||||
$this->type = $type;
|
||||
} elseif ($type instanceof KeyFragment) {
|
||||
} elseif ($type instanceof Key) {
|
||||
$this->key = $type;
|
||||
$this->isConstraint = $isConstraint;
|
||||
$this->references = $references;
|
||||
@ -119,13 +119,13 @@ class FieldDefFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return FieldDefFragment[]
|
||||
* @return FieldDefinition[]
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$expr = new FieldDefFragment();
|
||||
$expr = new FieldDefinition();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -176,7 +176,7 @@ class FieldDefFragment extends Fragment
|
||||
if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'CONSTRAINT')) {
|
||||
$expr->isConstraint = true;
|
||||
} elseif (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_KEY)) {
|
||||
$expr->key = KeyFragment::parse($parser, $list);
|
||||
$expr->key = Key::parse($parser, $list);
|
||||
$state = 4;
|
||||
} else {
|
||||
$expr->name = $token->value;
|
||||
@ -185,15 +185,15 @@ class FieldDefFragment extends Fragment
|
||||
}
|
||||
}
|
||||
} elseif ($state === 2) {
|
||||
$expr->type = DataTypeFragment::parse($parser, $list);
|
||||
$expr->type = DataType::parse($parser, $list);
|
||||
$state = 3;
|
||||
} elseif ($state === 3) {
|
||||
$expr->options = OptionsFragment::parse($parser, $list, static::$FIELD_OPTIONS);
|
||||
$expr->options = OptionsArray::parse($parser, $list, static::$FIELD_OPTIONS);
|
||||
$state = 4;
|
||||
} elseif ($state === 4) {
|
||||
if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'REFERENCES')) {
|
||||
++$list->idx; // Skipping keyword 'REFERENCES'.
|
||||
$expr->references = ReferencesKeyword::parse($parser, $list);
|
||||
$expr->references = Reference::parse($parser, $list);
|
||||
} else {
|
||||
--$list->idx;
|
||||
}
|
||||
@ -202,7 +202,7 @@ class FieldDefFragment extends Fragment
|
||||
if ((!empty($expr->type)) || (!empty($expr->key))) {
|
||||
$ret[] = $expr;
|
||||
}
|
||||
$expr = new FieldDefFragment();
|
||||
$expr = new FieldDefinition();
|
||||
if ($token->value === ',') {
|
||||
$state = 1;
|
||||
continue;
|
||||
@ -224,15 +224,15 @@ class FieldDefFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FieldDefFragment[] $fragment The fragment to be built.
|
||||
* @param FieldDefinition[] $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
foreach ($fragment as $f) {
|
||||
foreach ($component as $f) {
|
||||
$tmp = '';
|
||||
|
||||
if ($f->isConstraint) {
|
||||
@ -244,18 +244,18 @@ class FieldDefFragment extends Fragment
|
||||
}
|
||||
|
||||
if (!empty($f->type)) {
|
||||
$tmp .= DataTypeFragment::build($f->type) . ' ';
|
||||
$tmp .= DataType::build($f->type) . ' ';
|
||||
}
|
||||
|
||||
if (!empty($f->key)) {
|
||||
$tmp .= KeyFragment::build($f->key) . ' ';
|
||||
$tmp .= Key::build($f->key) . ' ';
|
||||
}
|
||||
|
||||
if (!empty($f->references)) {
|
||||
$tmp .= 'REFERENCES ' . ReferencesKeyword::build($f->references) . ' ';
|
||||
$tmp .= 'REFERENCES ' . Reference::build($f->references) . ' ';
|
||||
}
|
||||
|
||||
$tmp .= OptionsFragment::build($f->options);
|
||||
$tmp .= OptionsArray::build($f->options);
|
||||
|
||||
$ret[] = trim($tmp);
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* Parses a function call.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class CallKeyword extends Fragment
|
||||
class FunctionCall extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -35,7 +35,7 @@ class CallKeyword extends Fragment
|
||||
/**
|
||||
* The list of parameters
|
||||
*
|
||||
* @var ArrayFragment
|
||||
* @var ArrayObj
|
||||
*/
|
||||
public $parameters;
|
||||
|
||||
@ -43,14 +43,14 @@ class CallKeyword extends Fragment
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The name of the function to be called.
|
||||
* @param array|ArrayFragment $parameters The parameters of this function.
|
||||
* @param array|ArrayObj $parameters The parameters of this function.
|
||||
*/
|
||||
public function __construct($name = null, $parameters = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
if (is_array($parameters)) {
|
||||
$this->parameters = new ArrayFragment($parameters);
|
||||
} elseif ($parameters instanceof ArrayFragment) {
|
||||
$this->parameters = new ArrayObj($parameters);
|
||||
} elseif ($parameters instanceof ArrayObj) {
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
}
|
||||
@ -60,11 +60,11 @@ class CallKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return CallKeyword
|
||||
* @return FunctionCall
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new CallKeyword();
|
||||
$ret = new FunctionCall();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -101,7 +101,7 @@ class CallKeyword extends Fragment
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
|
||||
$ret->parameters = ArrayFragment::parse($parser, $list);
|
||||
$ret->parameters = ArrayObj::parse($parser, $list);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -112,12 +112,12 @@ class CallKeyword extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CallKeyword $fragment The fragment to be built.
|
||||
* @param FunctionCall $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
return $fragment->name . ArrayFragment::build($fragment->parameters);
|
||||
return $component->name . ArrayObj::build($component->parameters);
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* `INTO` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class IntoKeyword extends Fragment
|
||||
class IntoKeyword extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -35,7 +35,7 @@ class IntoKeyword extends Fragment
|
||||
/**
|
||||
* The destination, which can be a table or a file.
|
||||
*
|
||||
* @var string|FieldFragment
|
||||
* @var string|Expression
|
||||
*/
|
||||
public $dest;
|
||||
|
||||
@ -102,7 +102,7 @@ class IntoKeyword extends Fragment
|
||||
}
|
||||
|
||||
if ($state === 0) {
|
||||
$ret->dest = FieldFragment::parse(
|
||||
$ret->dest = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
array(
|
||||
@ -114,7 +114,7 @@ class IntoKeyword extends Fragment
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
|
||||
$ret->fields = ArrayFragment::parse($parser, $list)->values;
|
||||
$ret->fields = ArrayObj::parse($parser, $list)->values;
|
||||
++$list->idx;
|
||||
}
|
||||
break;
|
||||
@ -4,11 +4,11 @@
|
||||
* `JOIN` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,24 +18,24 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class JoinKeyword extends Fragment
|
||||
class JoinKeyword extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* Join expression.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Join conditions.
|
||||
*
|
||||
* @var WhereKeyword[]
|
||||
* @var Condition[]
|
||||
*/
|
||||
public $on;
|
||||
|
||||
@ -83,14 +83,14 @@ class JoinKeyword extends Fragment
|
||||
}
|
||||
|
||||
if ($state === 0) {
|
||||
$ret->expr = FieldFragment::parse($parser, $list, array('skipColumn' => true));
|
||||
$ret->expr = Expression::parse($parser, $list, array('skipColumn' => true));
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'ON')) {
|
||||
$state = 2;
|
||||
}
|
||||
} elseif ($state === 2) {
|
||||
$ret->on = WhereKeyword::parse($parser, $list);
|
||||
$ret->on = Condition::parse($parser, $list);
|
||||
++$list->idx;
|
||||
break;
|
||||
}
|
||||
@ -4,12 +4,12 @@
|
||||
* Parses the definition of a key.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Context;
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -19,13 +19,13 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* Used for parsing `CREATE TABLE` statement.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class KeyFragment extends Fragment
|
||||
class Key extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ class KeyFragment extends Fragment
|
||||
/**
|
||||
* The options of this key.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*/
|
||||
public $options;
|
||||
|
||||
@ -73,7 +73,7 @@ class KeyFragment extends Fragment
|
||||
* @param string $name The name of the key.
|
||||
* @param array $columns The columns covered by this key.
|
||||
* @param string $type The type of this key.
|
||||
* @param OptionsFragment $options The options of this key.
|
||||
* @param OptionsArray $options The options of this key.
|
||||
*/
|
||||
public function __construct($name = null, array $columns = array(),
|
||||
$type = null, $options = null
|
||||
@ -89,11 +89,11 @@ class KeyFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return KeyFragment[]
|
||||
* @return Key[]
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new KeyFragment();
|
||||
$ret = new Key();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -133,13 +133,13 @@ class KeyFragment extends Fragment
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
|
||||
$ret->columns = ArrayFragment::parse($parser, $list)->values;
|
||||
$ret->columns = ArrayObj::parse($parser, $list)->values;
|
||||
$state = 2;
|
||||
} else {
|
||||
$ret->name = $token->value;
|
||||
}
|
||||
} elseif ($state === 2) {
|
||||
$ret->options = OptionsFragment::parse($parser, $list, static::$KEY_OPTIONS);
|
||||
$ret->options = OptionsArray::parse($parser, $list, static::$KEY_OPTIONS);
|
||||
++$list->idx;
|
||||
break;
|
||||
}
|
||||
@ -151,18 +151,18 @@ class KeyFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KeyFragment $fragment The fragment to be built.
|
||||
* @param Key $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$ret = $fragment->type . ' ';
|
||||
if (!empty($fragment->name)) {
|
||||
$ret .= Context::escape($fragment->name) . ' ';
|
||||
$ret = $component->type . ' ';
|
||||
if (!empty($component->name)) {
|
||||
$ret .= Context::escape($component->name) . ' ';
|
||||
}
|
||||
$ret .= '(' . implode(', ', Context::escape($fragment->columns)) . ')';
|
||||
$ret .= OptionsFragment::build($fragment->options);
|
||||
$ret .= '(' . implode(', ', Context::escape($component->columns)) . ')';
|
||||
$ret .= OptionsArray::build($component->options);
|
||||
return trim($ret);
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* `LIMIT` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class LimitKeyword extends Fragment
|
||||
class Limit extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -56,11 +56,11 @@ class LimitKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return LimitKeyword
|
||||
* @return Limit
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new LimitKeyword();
|
||||
$ret = new Limit();
|
||||
|
||||
$offset = false;
|
||||
|
||||
@ -116,16 +116,16 @@ class LimitKeyword extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LimitKeyword $fragment The fragment to be built.
|
||||
* @param Limit $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
if (empty($fragment->offset)) {
|
||||
return $fragment->rowCount;
|
||||
if (empty($component->offset)) {
|
||||
return $component->rowCount;
|
||||
} else {
|
||||
return $fragment->offset . ', ' . $fragment->rowCount;
|
||||
return $component->offset . ', ' . $component->rowCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* Parses a list of options.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -16,17 +16,17 @@ use SqlParser\TokensList;
|
||||
/**
|
||||
* Parses a list of options.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class OptionsFragment extends Fragment
|
||||
class OptionsArray extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* Array of selected options.
|
||||
* ArrayObj of selected options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@ -48,11 +48,11 @@ class OptionsFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return OptionsFragment
|
||||
* @return OptionsArray
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new OptionsFragment();
|
||||
$ret = new OptionsArray();
|
||||
|
||||
/**
|
||||
* The ID that will be assigned to duplicate options.
|
||||
@ -150,17 +150,17 @@ class OptionsFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OptionsFragment $fragment The fragment to be built.
|
||||
* @param OptionsArray $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
if ((empty($fragment)) || (!is_array($fragment->options))) {
|
||||
if ((empty($component)) || (!is_array($component->options))) {
|
||||
return '';
|
||||
}
|
||||
$options = array();
|
||||
foreach ($fragment->options as $option) {
|
||||
foreach ($component->options as $option) {
|
||||
if (is_array($option)) {
|
||||
$options[] = $option['name']
|
||||
. (!empty($option['equal']) ? '=' : ' ')
|
||||
@ -195,7 +195,7 @@ class OptionsFragment extends Fragment
|
||||
* Merges the specified options with these ones. Values with same ID will be
|
||||
* replaced.
|
||||
*
|
||||
* @param array|OptionsFragment $options The options to be merged.
|
||||
* @param array|OptionsArray $options The options to be merged.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -203,7 +203,7 @@ class OptionsFragment extends Fragment
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$this->options = array_merge_recursive($this->options, $options);
|
||||
} elseif ($options instanceof OptionsFragment) {
|
||||
} elseif ($options instanceof OptionsArray) {
|
||||
$this->options = array_merge_recursive($this->options, $options->options);
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* `ORDER BY` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,17 +18,17 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class OrderKeyword extends Fragment
|
||||
class OrderKeyword extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* The field that is used for ordering.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $field;
|
||||
|
||||
@ -84,7 +84,7 @@ class OrderKeyword extends Fragment
|
||||
}
|
||||
|
||||
if ($state === 0) {
|
||||
$expr->field = FieldFragment::parse($parser, $list);
|
||||
$expr->field = Expression::parse($parser, $list);
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
if (($token->type === Token::TYPE_KEYWORD) && (($token->value === 'ASC') || ($token->value === 'DESC'))) {
|
||||
@ -4,12 +4,12 @@
|
||||
* The definition of a parameter of a function or procedure.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Context;
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -17,13 +17,13 @@ use SqlParser\TokensList;
|
||||
/**
|
||||
* The definition of a parameter of a function or procedure.
|
||||
*
|
||||
* @category Fragments
|
||||
* @category Components
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class ParamDefFragment extends Fragment
|
||||
class ParameterDefinition extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -43,7 +43,7 @@ class ParamDefFragment extends Fragment
|
||||
/**
|
||||
* The data type of thew new column.
|
||||
*
|
||||
* @var DataTypeFragment
|
||||
* @var DataType
|
||||
*/
|
||||
public $type;
|
||||
|
||||
@ -52,13 +52,13 @@ class ParamDefFragment extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return ParamDefFragment[]
|
||||
* @return ParameterDefinition[]
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$expr = new ParamDefFragment();
|
||||
$expr = new ParameterDefinition();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -113,11 +113,11 @@ class ParamDefFragment extends Fragment
|
||||
$state = 2;
|
||||
}
|
||||
} elseif ($state === 2) {
|
||||
$expr->type = DataTypeFragment::parse($parser, $list);
|
||||
$expr->type = DataType::parse($parser, $list);
|
||||
$state = 3;
|
||||
} elseif ($state === 3) {
|
||||
$ret[] = $expr;
|
||||
$expr = new ParamDefFragment();
|
||||
$expr = new ParameterDefinition();
|
||||
if ($token->value === ',') {
|
||||
$state = 1;
|
||||
continue;
|
||||
@ -138,14 +138,14 @@ class ParamDefFragment extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ParamDefFragment[] $fragment The fragment to be built.
|
||||
* @param ParameterDefinition[] $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($fragment as $f) {
|
||||
foreach ($component as $f) {
|
||||
$tmp = '';
|
||||
if (!empty($f->inOut)) {
|
||||
$tmp .= $f->inOut . ' ';
|
||||
@ -153,7 +153,7 @@ class ParamDefFragment extends Fragment
|
||||
|
||||
$ret[] = trim(
|
||||
$tmp . Context::escape($f->name) . ' ' .
|
||||
DataTypeFragment::build($f->type)
|
||||
DataType::build($f->type)
|
||||
);
|
||||
}
|
||||
return '(' . implode(', ', $ret) . ')';
|
||||
@ -4,12 +4,12 @@
|
||||
* `REFERENCES` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Context;
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -19,11 +19,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class ReferencesKeyword extends Fragment
|
||||
class Reference extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -54,7 +54,7 @@ class ReferencesKeyword extends Fragment
|
||||
/**
|
||||
* The options of the referencing.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*/
|
||||
public $options;
|
||||
|
||||
@ -63,7 +63,7 @@ class ReferencesKeyword extends Fragment
|
||||
*
|
||||
* @param string $table The name of the table referenced.
|
||||
* @param array $columns The columns referenced.
|
||||
* @param OptionsFragment $options The options.
|
||||
* @param OptionsArray $options The options.
|
||||
*/
|
||||
public function __construct($table = null, array $columns = array(), $options = null)
|
||||
{
|
||||
@ -77,11 +77,11 @@ class ReferencesKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return ReferencesKeyword
|
||||
* @return Reference
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = new ReferencesKeyword();
|
||||
$ret = new Reference();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -119,10 +119,10 @@ class ReferencesKeyword extends Fragment
|
||||
$ret->table = $token->value;
|
||||
$state = 1;
|
||||
} elseif ($state === 1) {
|
||||
$ret->columns = ArrayFragment::parse($parser, $list)->values;
|
||||
$ret->columns = ArrayObj::parse($parser, $list)->values;
|
||||
$state = 2;
|
||||
} elseif ($state === 2) {
|
||||
$ret->options = OptionsFragment::parse($parser, $list, static::$REFERENCES_OPTIONS);
|
||||
$ret->options = OptionsArray::parse($parser, $list, static::$REFERENCES_OPTIONS);
|
||||
++$list->idx;
|
||||
break;
|
||||
}
|
||||
@ -134,16 +134,16 @@ class ReferencesKeyword extends Fragment
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ReferencesKeyword $fragment The fragment to be built.
|
||||
* @param Reference $component The component to be built.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build($fragment)
|
||||
public static function build($component)
|
||||
{
|
||||
return trim(
|
||||
Context::escape($fragment->table)
|
||||
. ' (' . implode(', ', Context::escape($fragment->columns)) . ') '
|
||||
. OptionsFragment::build($fragment->options)
|
||||
Context::escape($component->table)
|
||||
. ' (' . implode(', ', Context::escape($component->columns)) . ') '
|
||||
. OptionsArray::build($component->options)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@
|
||||
* `RENAME TABLE` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,24 +18,24 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class RenameKeyword extends Fragment
|
||||
class RenameOperation extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* The old table name.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $old;
|
||||
|
||||
/**
|
||||
* The new table name.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $new;
|
||||
|
||||
@ -44,13 +44,13 @@ class RenameKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return RenameKeyword
|
||||
* @return RenameOperation
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$expr = new RenameKeyword();
|
||||
$expr = new RenameOperation();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -100,7 +100,7 @@ class RenameKeyword extends Fragment
|
||||
if ($token->type === Token::TYPE_OPERATOR) {
|
||||
if (($state === 3) && ($token->value === ',')) {
|
||||
$ret[] = $expr;
|
||||
$expr = new RenameKeyword();
|
||||
$expr = new RenameOperation();
|
||||
$state = 0;
|
||||
continue;
|
||||
}
|
||||
@ -110,7 +110,7 @@ class RenameKeyword extends Fragment
|
||||
}
|
||||
|
||||
if ($state == 0) {
|
||||
$expr->old = FieldFragment::parse(
|
||||
$expr->old = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
array(
|
||||
@ -121,7 +121,7 @@ class RenameKeyword extends Fragment
|
||||
);
|
||||
$state = 1;
|
||||
} elseif ($state == 2) {
|
||||
$expr->new = FieldFragment::parse(
|
||||
$expr->new = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
array(
|
||||
@ -4,11 +4,11 @@
|
||||
* `SET` keyword parser.
|
||||
*
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
*/
|
||||
namespace SqlParser\Fragments;
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Fragment;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
@ -18,11 +18,11 @@ use SqlParser\TokensList;
|
||||
*
|
||||
* @category Keywords
|
||||
* @package SqlParser
|
||||
* @subpackage Fragments
|
||||
* @subpackage Components
|
||||
* @author Dan Ungureanu <udan1107@gmail.com>
|
||||
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
||||
*/
|
||||
class SetKeyword extends Fragment
|
||||
class SetOperation extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
@ -44,13 +44,13 @@ class SetKeyword extends Fragment
|
||||
* @param TokensList $list The list of tokens that are being parsed.
|
||||
* @param array $options Parameters for parsing.
|
||||
*
|
||||
* @return SetKeyword[]
|
||||
* @return SetOperation[]
|
||||
*/
|
||||
public static function parse(Parser $parser, TokensList $list, array $options = array())
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$expr = new SetKeyword();
|
||||
$expr = new SetOperation();
|
||||
|
||||
/**
|
||||
* The state of the parser.
|
||||
@ -93,7 +93,7 @@ class SetKeyword extends Fragment
|
||||
$expr->column = trim($expr->column);
|
||||
$expr->value = trim($expr->value);
|
||||
$ret[] = $expr;
|
||||
$expr = new SetKeyword();
|
||||
$expr = new SetOperation();
|
||||
$state = 0;
|
||||
continue;
|
||||
} elseif ($token->value === '=') {
|
||||
@ -75,7 +75,7 @@ class Parser
|
||||
);
|
||||
|
||||
/**
|
||||
* Array of classes that are used in parsing SQL fragments.
|
||||
* Array of classes that are used in parsing SQL components.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@ -83,128 +83,128 @@ class Parser
|
||||
|
||||
// This is not a proper keyword and was added here to help the builder.
|
||||
'_OPTIONS' => array(
|
||||
'class' => 'SqlParser\\Fragments\\OptionsFragment',
|
||||
'class' => 'SqlParser\\Components\\OptionsArray',
|
||||
'field' => 'options',
|
||||
),
|
||||
|
||||
'ALTER' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldFragment',
|
||||
'class' => 'SqlParser\\Components\\Expression',
|
||||
'field' => 'table',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'ANALYZE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'BACKUP' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'CALL' => array(
|
||||
'class' => 'SqlParser\\Fragments\\CallKeyword',
|
||||
'class' => 'SqlParser\\Components\\FunctionCall',
|
||||
'field' => 'call',
|
||||
),
|
||||
'CHECK' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'CHECKSUM' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'DROP' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'fields',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'FROM' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'from',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'GROUP BY' => array(
|
||||
'class' => 'SqlParser\\Fragments\\OrderKeyword',
|
||||
'class' => 'SqlParser\\Components\\OrderKeyword',
|
||||
'field' => 'group',
|
||||
),
|
||||
'HAVING' => array(
|
||||
'class' => 'SqlParser\\Fragments\\WhereKeyword',
|
||||
'class' => 'SqlParser\\Components\\Condition',
|
||||
'field' => 'having',
|
||||
),
|
||||
'INTO' => array(
|
||||
'class' => 'SqlParser\\Fragments\\IntoKeyword',
|
||||
'class' => 'SqlParser\\Components\\IntoKeyword',
|
||||
'field' => 'into',
|
||||
),
|
||||
'JOIN' => array(
|
||||
'class' => 'SqlParser\\Fragments\\JoinKeyword',
|
||||
'class' => 'SqlParser\\Components\\JoinKeyword',
|
||||
'field' => 'join',
|
||||
),
|
||||
'LIMIT' => array(
|
||||
'class' => 'SqlParser\\Fragments\\LimitKeyword',
|
||||
'class' => 'SqlParser\\Components\\Limit',
|
||||
'field' => 'limit',
|
||||
),
|
||||
'OPTIMIZE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'ORDER BY' => array(
|
||||
'class' => 'SqlParser\\Fragments\\OrderKeyword',
|
||||
'class' => 'SqlParser\\Components\\OrderKeyword',
|
||||
'field' => 'order',
|
||||
),
|
||||
'PARTITION' => array(
|
||||
'class' => 'SqlParser\\Fragments\\ArrayFragment',
|
||||
'class' => 'SqlParser\\Components\\ArrayObj',
|
||||
'field' => 'partition',
|
||||
),
|
||||
'PROCEDURE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\CallKeyword',
|
||||
'class' => 'SqlParser\\Components\\FunctionCall',
|
||||
'field' => 'procedure',
|
||||
),
|
||||
'RENAME' => array(
|
||||
'class' => 'SqlParser\\Fragments\\RenameKeyword',
|
||||
'class' => 'SqlParser\\Components\\RenameOperation',
|
||||
'field' => 'renames',
|
||||
),
|
||||
'REPAIR' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'RESTORE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'SET' => array(
|
||||
'class' => 'SqlParser\\Fragments\\SetKeyword',
|
||||
'class' => 'SqlParser\\Components\\SetOperation',
|
||||
'field' => 'set',
|
||||
),
|
||||
'SELECT' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'expr',
|
||||
),
|
||||
'TRUNCATE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldFragment',
|
||||
'class' => 'SqlParser\\Components\\Expression',
|
||||
'field' => 'table',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'UPDATE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\FieldListFragment',
|
||||
'class' => 'SqlParser\\Components\\ExpressionArray',
|
||||
'field' => 'tables',
|
||||
'options' => array('skipColumn' => true),
|
||||
),
|
||||
'VALUE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\ValuesKeyword',
|
||||
'class' => 'SqlParser\\Components\\Array2d',
|
||||
'field' => 'values',
|
||||
),
|
||||
'VALUES' => array(
|
||||
'class' => 'SqlParser\\Fragments\\ValuesKeyword',
|
||||
'class' => 'SqlParser\\Components\\Array2d',
|
||||
'field' => 'values',
|
||||
),
|
||||
'WHERE' => array(
|
||||
'class' => 'SqlParser\\Fragments\\WhereKeyword',
|
||||
'class' => 'SqlParser\\Components\\Condition',
|
||||
'field' => 'where',
|
||||
),
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
*/
|
||||
namespace SqlParser;
|
||||
|
||||
use SqlParser\Fragments\OptionsFragment;
|
||||
use SqlParser\Components\OptionsArray;
|
||||
|
||||
/**
|
||||
* Abstract statement definition.
|
||||
@ -61,7 +61,7 @@ abstract class Statement
|
||||
/**
|
||||
* The options of this query.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*
|
||||
* @see static::$OPTIONS
|
||||
*/
|
||||
@ -233,7 +233,7 @@ abstract class Statement
|
||||
if (!empty(Parser::$STATEMENT_PARSERS[$token->value])) {
|
||||
if (!$parsedOptions) {
|
||||
++$list->idx; // Skipping keyword.
|
||||
$this->options = OptionsFragment::parse(
|
||||
$this->options = OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$OPTIONS
|
||||
|
||||
@ -12,9 +12,9 @@ use SqlParser\Parser;
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
use SqlParser\Fragments\AlterFragment;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Fragments\OptionsFragment;
|
||||
use SqlParser\Components\AlterOperation;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Components\OptionsArray;
|
||||
|
||||
/**
|
||||
* `ALTER` statement.
|
||||
@ -31,14 +31,14 @@ class AlterStatement extends Statement
|
||||
/**
|
||||
* Table affected.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $table;
|
||||
|
||||
/**
|
||||
* Column affected by this statement.
|
||||
*
|
||||
* @var AlterFragment[]
|
||||
* @var AlterOperation[]
|
||||
*/
|
||||
public $altered = array();
|
||||
|
||||
@ -62,7 +62,7 @@ class AlterStatement extends Statement
|
||||
public function parse(Parser $parser, TokensList $list)
|
||||
{
|
||||
++$list->idx; // Skipping `ALTER`.
|
||||
$this->options = OptionsFragment::parse(
|
||||
$this->options = OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$OPTIONS
|
||||
@ -72,7 +72,7 @@ class AlterStatement extends Statement
|
||||
$list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'TABLE');
|
||||
|
||||
// Parsing affected table.
|
||||
$this->table = FieldFragment::parse(
|
||||
$this->table = Expression::parse(
|
||||
$parser, $list, array(
|
||||
'noAlias' => true,
|
||||
'noBrackets' => true,
|
||||
@ -111,7 +111,7 @@ class AlterStatement extends Statement
|
||||
}
|
||||
|
||||
if ($state === 0) {
|
||||
$this->altered[] = AlterFragment::parse($parser, $list);
|
||||
$this->altered[] = AlterOperation::parse($parser, $list);
|
||||
$state = 1;
|
||||
} else if ($state === 1) {
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === ',')) {
|
||||
@ -131,8 +131,8 @@ class AlterStatement extends Statement
|
||||
$tmp[] = $altered::build($altered);
|
||||
}
|
||||
|
||||
return 'ALTER ' . OptionsFragment::build($this->options)
|
||||
. ' TABLE ' . FieldFragment::build($this->table)
|
||||
return 'ALTER ' . OptionsArray::build($this->options)
|
||||
. ' TABLE ' . Expression::build($this->table)
|
||||
. ' ' . implode(', ', $tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Components\Expression;
|
||||
|
||||
/**
|
||||
* `ANALYZE` statement.
|
||||
@ -42,7 +42,7 @@ class AnalyzeStatement extends Statement
|
||||
/**
|
||||
* Analyzed tables.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $tables;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\CallKeyword;
|
||||
use SqlParser\Components\FunctionCall;
|
||||
|
||||
/**
|
||||
* `CALL` statement.
|
||||
@ -32,7 +32,7 @@ class CallStatement extends Statement
|
||||
/**
|
||||
* The name of the function and its parameters.
|
||||
*
|
||||
* @var CallKeyword
|
||||
* @var FunctionCall
|
||||
*/
|
||||
public $call;
|
||||
}
|
||||
|
||||
@ -12,12 +12,12 @@ use SqlParser\Parser;
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
use SqlParser\Fragments\ArrayFragment;
|
||||
use SqlParser\Fragments\DataTypeFragment;
|
||||
use SqlParser\Fragments\FieldDefFragment;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Fragments\OptionsFragment;
|
||||
use SqlParser\Fragments\ParamDefFragment;
|
||||
use SqlParser\Components\ArrayObj;
|
||||
use SqlParser\Components\DataType;
|
||||
use SqlParser\Components\FieldDefinition;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Components\OptionsArray;
|
||||
use SqlParser\Components\ParameterDefinition;
|
||||
|
||||
/**
|
||||
* `CREATE` statement.
|
||||
@ -146,7 +146,7 @@ class CreateStatement extends Statement
|
||||
*
|
||||
* Used by all `CREATE` statements.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $name;
|
||||
|
||||
@ -155,7 +155,7 @@ class CreateStatement extends Statement
|
||||
*
|
||||
* Used by `CREATE TABLE`, `CREATE FUNCTION` and `CREATE PROCEDURE`.
|
||||
*
|
||||
* @var OptionsFragment
|
||||
* @var OptionsArray
|
||||
*
|
||||
* @see static::$TABLE_OPTIONS
|
||||
* @see static::$FUNC_OPTIONS
|
||||
@ -169,7 +169,7 @@ class CreateStatement extends Statement
|
||||
*
|
||||
* Used by `CREATE TABLE` and `CREATE VIEW`.
|
||||
*
|
||||
* @var FieldDefFragment[]|ArrayFragment
|
||||
* @var FieldDefinition[]|ArrayObj
|
||||
*/
|
||||
public $fields;
|
||||
|
||||
@ -178,7 +178,7 @@ class CreateStatement extends Statement
|
||||
*
|
||||
* Used by `CREATE TRIGGER`.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $table;
|
||||
|
||||
@ -187,7 +187,7 @@ class CreateStatement extends Statement
|
||||
*
|
||||
* Used by `CREATE FUNCTION`.
|
||||
*
|
||||
* @var DataTypeFragment
|
||||
* @var DataType
|
||||
*/
|
||||
public $return;
|
||||
|
||||
@ -196,7 +196,7 @@ class CreateStatement extends Statement
|
||||
*
|
||||
* Used by `CREATE FUNCTION` and `CREATE PROCEDURE`.
|
||||
*
|
||||
* @var ParamDefFragment[]
|
||||
* @var ParameterDefinition[]
|
||||
*/
|
||||
public $parameters;
|
||||
|
||||
@ -217,43 +217,43 @@ class CreateStatement extends Statement
|
||||
{
|
||||
if ($this->options->has('DATABASE')) {
|
||||
return 'CREATE '
|
||||
. OptionsFragment::build($this->options) . ' '
|
||||
. FieldFragment::build($this->name) . ' '
|
||||
. OptionsFragment::build($this->entityOptions);
|
||||
. OptionsArray::build($this->options) . ' '
|
||||
. Expression::build($this->name) . ' '
|
||||
. OptionsArray::build($this->entityOptions);
|
||||
} elseif ($this->options->has('TABLE')) {
|
||||
return 'CREATE '
|
||||
. OptionsFragment::build($this->options) . ' '
|
||||
. FieldFragment::build($this->name) . ' '
|
||||
. FieldDefFragment::build($this->fields) . ' '
|
||||
. OptionsFragment::build($this->entityOptions);
|
||||
. OptionsArray::build($this->options) . ' '
|
||||
. Expression::build($this->name) . ' '
|
||||
. FieldDefinition::build($this->fields) . ' '
|
||||
. OptionsArray::build($this->entityOptions);
|
||||
} elseif ($this->options->has('VIEW')) {
|
||||
$tmp = '';
|
||||
if (!empty($this->fields)) {
|
||||
$tmp = ArrayFragment::build($this->fields);
|
||||
$tmp = ArrayObj::build($this->fields);
|
||||
}
|
||||
return 'CREATE '
|
||||
. OptionsFragment::build($this->options) . ' '
|
||||
. FieldFragment::build($this->name) . ' '
|
||||
. OptionsArray::build($this->options) . ' '
|
||||
. Expression::build($this->name) . ' '
|
||||
. $tmp . ' AS ' . TokensList::build($this->body) . ' '
|
||||
. OptionsFragment::build($this->entityOptions);
|
||||
. OptionsArray::build($this->entityOptions);
|
||||
} elseif ($this->options->has('TRIGGER')) {
|
||||
return 'CREATE '
|
||||
. OptionsFragment::build($this->options) . ' '
|
||||
. FieldFragment::build($this->name) . ' '
|
||||
. OptionsFragment::build($this->entityOptions) . ' '
|
||||
. 'ON ' . FieldFragment::build($this->table) . ' '
|
||||
. OptionsArray::build($this->options) . ' '
|
||||
. Expression::build($this->name) . ' '
|
||||
. OptionsArray::build($this->entityOptions) . ' '
|
||||
. 'ON ' . Expression::build($this->table) . ' '
|
||||
. 'FOR EACH ROW ' . TokensList::build($this->body);
|
||||
} elseif (($this->options->has('PROCEDURE'))
|
||||
|| ($this->options->has('FUNCTION'))
|
||||
) {
|
||||
$tmp = '';
|
||||
if ($this->options->has('FUNCTION')) {
|
||||
$tmp = 'RETURNS ' . DataTypeFragment::build($this->return);
|
||||
$tmp = 'RETURNS ' . DataType::build($this->return);
|
||||
}
|
||||
return 'CREATE '
|
||||
. OptionsFragment::build($this->options) . ' '
|
||||
. FieldFragment::build($this->name) . ' '
|
||||
. ParamDefFragment::build($this->parameters) . ' '
|
||||
. OptionsArray::build($this->options) . ' '
|
||||
. Expression::build($this->name) . ' '
|
||||
. ParameterDefinition::build($this->parameters) . ' '
|
||||
. $tmp . ' ' . TokensList::build($this->body);
|
||||
}
|
||||
return '';
|
||||
@ -270,11 +270,11 @@ class CreateStatement extends Statement
|
||||
++$list->idx; // Skipping `CREATE`.
|
||||
|
||||
// Parsing options.
|
||||
$this->options = OptionsFragment::parse($parser, $list, static::$OPTIONS);
|
||||
$this->options = OptionsArray::parse($parser, $list, static::$OPTIONS);
|
||||
++$list->idx; // Skipping last option.
|
||||
|
||||
// Parsing the field name.
|
||||
$this->name = FieldFragment::parse(
|
||||
$this->name = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
array(
|
||||
@ -286,16 +286,16 @@ class CreateStatement extends Statement
|
||||
++$list->idx; // Skipping field.
|
||||
|
||||
if ($this->options->has('DATABASE')) {
|
||||
$this->entityOptions = OptionsFragment::parse(
|
||||
$this->entityOptions = OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$DB_OPTIONS
|
||||
);
|
||||
} elseif ($this->options->has('TABLE')) {
|
||||
$this->fields = FieldDefFragment::parse($parser, $list);
|
||||
$this->fields = FieldDefinition::parse($parser, $list);
|
||||
++$list->idx;
|
||||
|
||||
$this->entityOptions = OptionsFragment::parse(
|
||||
$this->entityOptions = OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$TABLE_OPTIONS
|
||||
@ -303,7 +303,7 @@ class CreateStatement extends Statement
|
||||
} elseif (($this->options->has('PROCEDURE'))
|
||||
|| ($this->options->has('FUNCTION'))
|
||||
) {
|
||||
$this->parameters = ParamDefFragment::parse($parser, $list);
|
||||
$this->parameters = ParameterDefinition::parse($parser, $list);
|
||||
if ($this->options->has('FUNCTION')) {
|
||||
$token = $list->getNextOfType(Token::TYPE_KEYWORD);
|
||||
if ($token->value !== 'RETURNS') {
|
||||
@ -313,7 +313,7 @@ class CreateStatement extends Statement
|
||||
);
|
||||
} else {
|
||||
++$list->idx;
|
||||
$this->return = DataTypeFragment::parse(
|
||||
$this->return = DataType::parse(
|
||||
$parser,
|
||||
$list
|
||||
);
|
||||
@ -321,7 +321,7 @@ class CreateStatement extends Statement
|
||||
}
|
||||
++$list->idx;
|
||||
|
||||
$this->entityOptions = OptionsFragment::parse(
|
||||
$this->entityOptions = OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$FUNC_OPTIONS
|
||||
@ -338,7 +338,7 @@ class CreateStatement extends Statement
|
||||
// Parsing columns list.
|
||||
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
|
||||
--$list->idx; // getNext() also goes forward one field.
|
||||
$this->fields = ArrayFragment::parse($parser, $list);
|
||||
$this->fields = ArrayObj::parse($parser, $list);
|
||||
++$list->idx; // Skipping last token from the array.
|
||||
$list->getNext();
|
||||
}
|
||||
@ -353,7 +353,7 @@ class CreateStatement extends Statement
|
||||
}
|
||||
} else if ($this->options->has('TRIGGER')) {
|
||||
// Parsing the time and the event.
|
||||
$this->entityOptions = OptionsFragment::parse(
|
||||
$this->entityOptions = OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$TRIGGER_OPTIONS
|
||||
@ -364,7 +364,7 @@ class CreateStatement extends Statement
|
||||
++$list->idx; // Skipping `ON`.
|
||||
|
||||
// Parsing the name of the table.
|
||||
$this->table = FieldFragment::parse(
|
||||
$this->table = Expression::parse(
|
||||
$parser,
|
||||
$list,
|
||||
array(
|
||||
|
||||
@ -9,11 +9,11 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\ArrayFragment;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Fragments\LimitKeyword;
|
||||
use SqlParser\Fragments\OrderKeyword;
|
||||
use SqlParser\Fragments\WhereKeyword;
|
||||
use SqlParser\Components\ArrayObj;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Components\Limit;
|
||||
use SqlParser\Components\OrderKeyword;
|
||||
use SqlParser\Components\Condition;
|
||||
|
||||
/**
|
||||
* `DELETE` statement.
|
||||
@ -65,21 +65,21 @@ class DeleteStatement extends Statement
|
||||
/**
|
||||
* Tables used as sources for this statement.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $from;
|
||||
|
||||
/**
|
||||
* Partitions used as source for this statement.
|
||||
*
|
||||
* @var ArrayFragment
|
||||
* @var ArrayObj
|
||||
*/
|
||||
public $partition;
|
||||
|
||||
/**
|
||||
* Conditions used for filtering each row of the result set.
|
||||
*
|
||||
* @var WhereKeyword[]
|
||||
* @var Condition[]
|
||||
*/
|
||||
public $where;
|
||||
|
||||
@ -93,7 +93,7 @@ class DeleteStatement extends Statement
|
||||
/**
|
||||
* Conditions used for limiting the size of the result set.
|
||||
*
|
||||
* @var LimitKeyword
|
||||
* @var Limit
|
||||
*/
|
||||
public $limit;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Components\Expression;
|
||||
|
||||
/**
|
||||
* `DROP` statement.
|
||||
@ -64,7 +64,7 @@ class DropStatement extends Statement
|
||||
/**
|
||||
* Dropped elements.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $fields;
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\IntoKeyword;
|
||||
use SqlParser\Fragments\ValuesKeyword;
|
||||
use SqlParser\Components\IntoKeyword;
|
||||
use SqlParser\Components\Array2d;
|
||||
|
||||
/**
|
||||
* `INSERT` statement.
|
||||
@ -76,7 +76,7 @@ class InsertStatement extends Statement
|
||||
/**
|
||||
* Values to be inserted.
|
||||
*
|
||||
* @var ValuesKeyword
|
||||
* @var Array2d
|
||||
*/
|
||||
public $values;
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ use SqlParser\Parser;
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Fragments\OptionsFragment;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Components\OptionsArray;
|
||||
|
||||
/**
|
||||
* Maintenance statement.
|
||||
@ -33,14 +33,14 @@ class MaintenanceStatement extends Statement
|
||||
/**
|
||||
* Tables maintained.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $tables;
|
||||
|
||||
/**
|
||||
* Function called after the token was processed.
|
||||
*
|
||||
* Parses the additional options fragment at the end.
|
||||
* Parses the additional options from the end.
|
||||
*
|
||||
* @param Parser $parser The instance that requests parsing.
|
||||
* @param TokensList $list The list of tokens to be parsed.
|
||||
@ -58,7 +58,7 @@ class MaintenanceStatement extends Statement
|
||||
// Finally, we parse here [some more options] and that's all.
|
||||
++$list->idx;
|
||||
$this->options->merge(
|
||||
OptionsFragment::parse(
|
||||
OptionsArray::parse(
|
||||
$parser,
|
||||
$list,
|
||||
static::$OPTIONS
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Components\Expression;
|
||||
|
||||
/**
|
||||
* `OPTIMIZE` statement.
|
||||
@ -42,7 +42,7 @@ class OptimizeStatement extends Statement
|
||||
/**
|
||||
* Optimized tables.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $tables;
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ use SqlParser\Parser;
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
use SqlParser\Fragments\RenameKeyword;
|
||||
use SqlParser\Components\RenameOperation;
|
||||
|
||||
/**
|
||||
* `RENAME` statement.
|
||||
@ -32,7 +32,7 @@ class RenameStatement extends Statement
|
||||
/**
|
||||
* The old and new names of the tables.
|
||||
*
|
||||
* @var RenameKeyword[]
|
||||
* @var RenameOperation[]
|
||||
*/
|
||||
public $renames;
|
||||
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\IntoKeyword;
|
||||
use SqlParser\Fragments\SetKeyword;
|
||||
use SqlParser\Fragments\ValuesKeyword;
|
||||
use SqlParser\Components\IntoKeyword;
|
||||
use SqlParser\Components\SetOperation;
|
||||
use SqlParser\Components\Array2d;
|
||||
|
||||
/**
|
||||
* `REPLACE` statement.
|
||||
@ -55,14 +55,14 @@ class ReplaceStatement extends Statement
|
||||
/**
|
||||
* Values to be replaced.
|
||||
*
|
||||
* @var ValuesKeyword
|
||||
* @var Array2d
|
||||
*/
|
||||
public $values;
|
||||
|
||||
/**
|
||||
* The replaced values.
|
||||
*
|
||||
* @var SetKeyword[]
|
||||
* @var SetOperation[]
|
||||
*/
|
||||
public $set;
|
||||
}
|
||||
|
||||
@ -9,14 +9,14 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\ArrayFragment;
|
||||
use SqlParser\Fragments\CallKeyword;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Fragments\IntoKeyword;
|
||||
use SqlParser\Fragments\JoinKeyword;
|
||||
use SqlParser\Fragments\LimitKeyword;
|
||||
use SqlParser\Fragments\OrderKeyword;
|
||||
use SqlParser\Fragments\WhereKeyword;
|
||||
use SqlParser\Components\ArrayObj;
|
||||
use SqlParser\Components\FunctionCall;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Components\IntoKeyword;
|
||||
use SqlParser\Components\JoinKeyword;
|
||||
use SqlParser\Components\Limit;
|
||||
use SqlParser\Components\OrderKeyword;
|
||||
use SqlParser\Components\Condition;
|
||||
|
||||
/**
|
||||
* `SELECT` statement.
|
||||
@ -104,28 +104,28 @@ class SelectStatement extends Statement
|
||||
/**
|
||||
* Expressions that are being selected by this statement.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $expr = array();
|
||||
|
||||
/**
|
||||
* Tables used as sources for this statement.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $from = array();
|
||||
|
||||
/**
|
||||
* Partitions used as source for this statement.
|
||||
*
|
||||
* @var ArrayFragment
|
||||
* @var ArrayObj
|
||||
*/
|
||||
public $partition;
|
||||
|
||||
/**
|
||||
* Conditions used for filtering each row of the result set.
|
||||
*
|
||||
* @var WhereKeyword[]
|
||||
* @var Condition[]
|
||||
*/
|
||||
public $where;
|
||||
|
||||
@ -139,7 +139,7 @@ class SelectStatement extends Statement
|
||||
/**
|
||||
* Conditions used for filtering the result set.
|
||||
*
|
||||
* @var WhereKeyword[]
|
||||
* @var Condition[]
|
||||
*/
|
||||
public $having;
|
||||
|
||||
@ -153,14 +153,14 @@ class SelectStatement extends Statement
|
||||
/**
|
||||
* Conditions used for limiting the size of the result set.
|
||||
*
|
||||
* @var LimitKeyword
|
||||
* @var Limit
|
||||
*/
|
||||
public $limit;
|
||||
|
||||
/**
|
||||
* Procedure that should process the data in the result set.
|
||||
*
|
||||
* @var CallKeyword
|
||||
* @var FunctionCall
|
||||
*/
|
||||
public $procedure;
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Components\Expression;
|
||||
|
||||
/**
|
||||
* `TRUNCATE` statement.
|
||||
@ -35,7 +35,7 @@ class TruncateStatement extends Statement
|
||||
/**
|
||||
* The name of the truncated table.
|
||||
*
|
||||
* @var FieldFragment
|
||||
* @var Expression
|
||||
*/
|
||||
public $table;
|
||||
}
|
||||
|
||||
@ -9,11 +9,11 @@
|
||||
namespace SqlParser\Statements;
|
||||
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Fragments\LimitKeyword;
|
||||
use SqlParser\Fragments\OrderKeyword;
|
||||
use SqlParser\Fragments\SetKeyword;
|
||||
use SqlParser\Fragments\WhereKeyword;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Components\Limit;
|
||||
use SqlParser\Components\OrderKeyword;
|
||||
use SqlParser\Components\SetOperation;
|
||||
use SqlParser\Components\Condition;
|
||||
|
||||
/**
|
||||
* `UPDATE` statement.
|
||||
@ -71,21 +71,21 @@ class UpdateStatement extends Statement
|
||||
/**
|
||||
* Tables used as sources for this statement.
|
||||
*
|
||||
* @var FieldFragment[]
|
||||
* @var Expression[]
|
||||
*/
|
||||
public $tables;
|
||||
|
||||
/**
|
||||
* The updated values.
|
||||
*
|
||||
* @var SetKeyword[]
|
||||
* @var SetOperation[]
|
||||
*/
|
||||
public $set;
|
||||
|
||||
/**
|
||||
* Conditions used for filtering each row of the result set.
|
||||
*
|
||||
* @var WhereKeyword[]
|
||||
* @var Condition[]
|
||||
*/
|
||||
public $where;
|
||||
|
||||
@ -99,7 +99,7 @@ class UpdateStatement extends Statement
|
||||
/**
|
||||
* Conditions used for limiting the size of the result set.
|
||||
*
|
||||
* @var LimitKeyword
|
||||
* @var Limit
|
||||
*/
|
||||
public $limit;
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ use SqlParser\Parser;
|
||||
use SqlParser\Statement;
|
||||
use SqlParser\Token;
|
||||
use SqlParser\TokensList;
|
||||
use SqlParser\Fragments\FieldFragment;
|
||||
use SqlParser\Components\Expression;
|
||||
use SqlParser\Statements\AlterStatement;
|
||||
use SqlParser\Statements\AnalyzeStatement;
|
||||
use SqlParser\Statements\CallStatement;
|
||||
@ -482,7 +482,7 @@ class Query
|
||||
if (!empty($field->table)) {
|
||||
$field->expr = null; // Force rebuild.
|
||||
$field->alias = null; // Aliases are not required.
|
||||
$ret[] = FieldFragment::build($field);
|
||||
$ret[] = Expression::build($field);
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
|
||||
@ -10,8 +10,8 @@ namespace SqlParser\Utils;
|
||||
|
||||
use SqlParser\Lexer;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Fragments\DataTypeFragment;
|
||||
use SqlParser\Fragments\ParamDefFragment;
|
||||
use SqlParser\Components\DataType;
|
||||
use SqlParser\Components\ParameterDefinition;
|
||||
use SqlParser\Statements\CreateStatement;
|
||||
|
||||
/**
|
||||
@ -38,7 +38,7 @@ class Routine
|
||||
$lexer = new Lexer($param);
|
||||
|
||||
// A dummy parser is used for error reporting.
|
||||
$type = DataTypeFragment::parse(new Parser(), $lexer->list);
|
||||
$type = DataType::parse(new Parser(), $lexer->list);
|
||||
|
||||
if ($type === null) {
|
||||
return array('', '', '', '', '');
|
||||
@ -70,7 +70,7 @@ class Routine
|
||||
$lexer = new Lexer('(' . $param . ')');
|
||||
|
||||
// A dummy parser is used for error reporting.
|
||||
$param = ParamDefFragment::parse(new Parser(), $lexer->list);
|
||||
$param = ParameterDefinition::parse(new Parser(), $lexer->list);
|
||||
|
||||
if (empty($param[0])) {
|
||||
return array('', '', '', '', '');
|
||||
|
||||
@ -138,8 +138,8 @@ if (! empty($sql_query)) {
|
||||
|
||||
// Rebuilding the SELECT and FROM clauses.
|
||||
$replaces = array(
|
||||
array('SELECT', 'SELECT ' . SqlParser\Fragments\FieldListFragment::build($parser->statements[0]->expr)),
|
||||
array('FROM', 'FROM ' . SqlParser\Fragments\FieldListFragment::build($parser->statements[0]->from)),
|
||||
array('SELECT', 'SELECT ' . SqlParser\Components\ExpressionArray::build($parser->statements[0]->expr)),
|
||||
array('FROM', 'FROM ' . SqlParser\Components\ExpressionArray::build($parser->statements[0]->from)),
|
||||
);
|
||||
|
||||
// Checking if the WHERE clause has to be replaced.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user