diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-24 23:40:09 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-25 00:02:57 +0300 |
commit | 997d824f8e066a64b121e60f6631e53c44fbb28f (patch) | |
tree | 7af902ff8684106df73f7cc8a928c1324f87eed4 /src | |
parent | de326a433bcb827360f7c4c8b0ea57e92d6f3a18 (diff) | |
download | sql-parser-997d824f8e066a64b121e60f6631e53c44fbb28f.zip sql-parser-997d824f8e066a64b121e60f6631e53c44fbb28f.tar.gz sql-parser-997d824f8e066a64b121e60f6631e53c44fbb28f.tar.bz2 |
Using the usual parsing method for transactions.
Diffstat (limited to 'src')
-rw-r--r-- | src/Parser.php | 3 | ||||
-rw-r--r-- | src/Statement.php | 9 | ||||
-rw-r--r-- | src/Statements/TransactionStatement.php | 6 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/Parser.php b/src/Parser.php index 36b6aec..249291c 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -436,6 +436,9 @@ namespace SqlParser { $this->statements[] = $statement; } elseif ($statement->type === TransactionStatement::TYPE_END) { if ($lastTransaction === null) { + // Even though an error occurred, the query is being + // saved. + $this->statements[] = $statement; $this->error( __('No transaction was previously started.'), $token diff --git a/src/Statement.php b/src/Statement.php index ea433c6..07d73d6 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -188,7 +188,7 @@ abstract class Statement * default. * @var bool $parsedOptions */ - $parsedOptions = !empty(static::$OPTIONS) ? false : true; + $parsedOptions = empty(static::$OPTIONS); for (; $list->idx < $list->count; ++$list->idx) { /** @@ -257,7 +257,10 @@ abstract class Statement } $parsedBeginning = true; if (!$parsedOptions) { - ++$list->idx; // Skipping keyword. + if (empty(static::$OPTIONS[$token->value])) { + // Skipping keyword because if it is not a option. + ++$list->idx; + } $this->options = OptionsArray::parse( $parser, $list, @@ -276,7 +279,7 @@ abstract class Statement // Parsing this keyword. if ($class !== null) { - ++$list->idx; // Skipping keyword. + ++$list->idx; // Skipping keyword or last option. $this->$field = $class::parse($parser, $list, $options); } diff --git a/src/Statements/TransactionStatement.php b/src/Statements/TransactionStatement.php index e7a13de..d7c9dbf 100644 --- a/src/Statements/TransactionStatement.php +++ b/src/Statements/TransactionStatement.php @@ -88,11 +88,7 @@ class TransactionStatement extends Statement */ public function parse(Parser $parser, TokensList $list) { - $this->options = OptionsArray::parse( - $parser, - $list, - static::$OPTIONS - ); + parent::parse($parser, $list); // Checks the type of this query. if (($this->options->has('START TRANSACTION')) |