57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* `RENAME` statement.
|
|
*
|
|
* @package SqlParser
|
|
* @subpackage Statements
|
|
*/
|
|
namespace SqlParser\Statements;
|
|
|
|
use SqlParser\Parser;
|
|
use SqlParser\Statement;
|
|
use SqlParser\Token;
|
|
use SqlParser\TokensList;
|
|
|
|
/**
|
|
* `RENAME` statement.
|
|
*
|
|
* RENAME TABLE tbl_name TO new_tbl_name
|
|
* [, tbl_name2 TO new_tbl_name2] ...
|
|
*
|
|
* @category Statements
|
|
* @package SqlParser
|
|
* @subpackage Statements
|
|
* @author Dan Ungureanu <udan1107@gmail.com>
|
|
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License
|
|
*/
|
|
class RenameStatement extends Statement
|
|
{
|
|
|
|
/**
|
|
* The old and new names of the tables.
|
|
*
|
|
* @var RenameKeyword[]
|
|
*/
|
|
public $renames;
|
|
|
|
/**
|
|
* Function called before the token is processed.
|
|
*
|
|
* Skips the `TABLE` keyword after `RENAME`.
|
|
*
|
|
* @param Parser $parser The instance that requests parsing.
|
|
* @param TokensList $list The list of tokens to be parsed.
|
|
* @param Token $token The token that is being parsed.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function before(Parser $parser, TokensList $list, Token $token)
|
|
{
|
|
if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'RENAME')) {
|
|
// Checking if it is the beginning of the query.
|
|
$list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'TABLE');
|
|
}
|
|
}
|
|
}
|