1
0
Fork 0

Fixed exception in DocBlock.

Removed code, that is no longer required.
Changed exception message, if auto-loader can not load statement parser class.
Dieser Commit ist enthalten in:
D4rk4ng3l 2011-06-19 16:10:32 +00:00
Ursprung 2d8e59b0b2
Commit 78a049635a

Datei anzeigen

@ -41,42 +41,6 @@ class Msd_Sql_Parser implements Iterator
*/ */
private $_parsingSummary = array(); private $_parsingSummary = array();
/**
* Available MySQL statements, divided and sorted by their length.
*
* @var array
*/
protected $_sqlStatements = array(
2 => array(
'do', 'xa'
),
3 => array(
'set', 'use'
),
4 => array(
'call', 'drop', 'help', 'kill', 'load', 'lock', 'show'
),
5 => array(
'alter', 'check', 'flush', 'grant', 'purge', 'reset', 'slave', 'start'
),
6 => array(
'backup', 'change', 'commit', 'create', 'delete', 'insert', 'rename', 'repair', 'revoke', 'select',
'unlock', 'update'
),
7 => array(
'analyze', 'execute', 'handler', 'install', 'preload', 'prepare', 'release', 'replace', 'restore'
),
8 => array(
'checksum', 'describe', 'optimize', 'keycache', 'rollback', 'truncate'
),
9 => array(
'savepoint', 'uninstall'
),
10 => array(
'deallocate'
),
);
/** /**
* MySQL comment types. * MySQL comment types.
* *
@ -143,7 +107,7 @@ class Msd_Sql_Parser implements Iterator
while ($startPos < $queryLength) { while ($startPos < $queryLength) {
$statementCounter++; $statementCounter++;
// move pointer to the next character we can interprete // move pointer to the next character we can interprete
WHILE ($startPos < $queryLength && in_array($sqlQuery[$startPos], array(' ', "\n", "\r"))) { while ($startPos < $queryLength && in_array($sqlQuery[$startPos], array(' ', "\n", "\r"))) {
$startPos++; $startPos++;
} }
@ -168,13 +132,6 @@ class Msd_Sql_Parser implements Iterator
continue; continue;
} }
$statementLength = strlen($statement);
if (
!isset($this->_sqlStatements[$statementLength]) ||
!in_array($statement, $this->_sqlStatements[$statementLength])
) {
throw new Msd_Sql_Parser_Exception("Unknown MySQL statement is found: '$statement'");
}
$parserClass = 'Msd_Sql_Parser_Statement_' . ucwords($statement); $parserClass = 'Msd_Sql_Parser_Statement_' . ucwords($statement);
$endPos = $this->_getStatementEndPos($sqlQuery, $startPos); $endPos = $this->_getStatementEndPos($sqlQuery, $startPos);
$completeStatement = trim(substr($sqlQuery, $startPos, $endPos - $startPos)); $completeStatement = trim(substr($sqlQuery, $startPos, $endPos - $startPos));
@ -227,7 +184,8 @@ class Msd_Sql_Parser implements Iterator
/** /**
* Creates an instance of a statement parser class and invokes statement parsing. * Creates an instance of a statement parser class and invokes statement parsing.
* *
* @throws Exception * @throws Msd_Sql_Parser_Exception
*
* @param string $statement MySQL statement to parse * @param string $statement MySQL statement to parse
* @param string $parserClass Parser class to use * @param string $parserClass Parser class to use
* *
@ -238,7 +196,7 @@ class Msd_Sql_Parser implements Iterator
try { try {
$parserObject = new $parserClass; $parserObject = new $parserClass;
} catch (Exception $e) { } catch (Exception $e) {
throw new Msd_Sql_Parser_Exception('The given parser class must implement Msd_Sql_Parser_Interface!'); throw new Msd_Sql_Parser_Exception("Can't suitable parser for the statement!");
} }
return $parserObject->parse($statement); return $parserObject->parse($statement);