commit
e75eca5a3c
@ -40,6 +40,7 @@ class Condition extends Component
|
||||
public static $OPERATORS = array(
|
||||
'AND' => 1,
|
||||
'BETWEEN' => 1,
|
||||
'EXISTS' => 1,
|
||||
'IN' => 1,
|
||||
'IS' => 1,
|
||||
'LIKE' => 1,
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
*/
|
||||
namespace SqlParser\Components;
|
||||
|
||||
use SqlParser\Context;
|
||||
use SqlParser\Component;
|
||||
use SqlParser\Parser;
|
||||
use SqlParser\Token;
|
||||
|
||||
@ -524,5 +524,5 @@ abstract class Context
|
||||
}
|
||||
}
|
||||
|
||||
// Initialing the default context.
|
||||
// Initializing the default context.
|
||||
Context::load();
|
||||
|
||||
@ -171,7 +171,7 @@ class Lexer
|
||||
*/
|
||||
public static function getTokens($str, $strict = false, $delimiter = null)
|
||||
{
|
||||
$lexer = new Lexer($str);
|
||||
$lexer = new Lexer($str, $strict, $delimiter);
|
||||
return $lexer->list;
|
||||
}
|
||||
|
||||
|
||||
@ -108,6 +108,20 @@ abstract class Statement
|
||||
*/
|
||||
$query = '';
|
||||
|
||||
/**
|
||||
* Clauses which were built already.
|
||||
*
|
||||
* It is required to keep track of built clauses because some fields,
|
||||
* for example `join` is used by multiple clauses (`JOIN`, `LEFT JOIN`,
|
||||
* `LEFT OUTER JOIN`, etc.). The same happens for `VALUE` and `VALUES`.
|
||||
*
|
||||
* A clause is considered built just after fields' value
|
||||
* (`$this->field`) was used in building.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$built = array();
|
||||
|
||||
foreach (static::$CLAUSES as $clause) {
|
||||
/**
|
||||
* The name of the clause.
|
||||
@ -144,6 +158,15 @@ abstract class Statement
|
||||
continue;
|
||||
}
|
||||
|
||||
// Checking if this field was already built.
|
||||
if ($type & 1) {
|
||||
if (!empty($built[$field])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$built[$field] = true;
|
||||
}
|
||||
|
||||
// Checking if the name of the clause should be added.
|
||||
if ($type & 2) {
|
||||
$query .= $name . ' ';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user