TYPO3
7.6
|
Public Member Functions | |
__construct (DatabaseConnection $databaseConnection=null) | |
parseSQL ($parseString) | |
parseFieldList (&$parseString, $stopRegex= '') | |
parseFromTables (&$parseString, $stopRegex= '') | |
parseWhereClause (&$parseString, $stopRegex= '', array &$parameterReferences=array()) | |
parseFieldDef (&$parseString, $stopRegex= '') | |
checkEmptyDefaultValue ($featureIndex) | |
compileSQL ($components) | |
compileFieldList ($selectFields, $compileComments=true) | |
compileFromTables ($tablesArray) | |
compileFieldCfg ($fieldCfg) | |
compileWhereClause ($clauseArray, $functionMapping=true) | |
debug_testSQL ($SQLquery) | |
debug_parseSQLpart ($part, $str) | |
debug_parseSQLpartCompare ($str, $newStr, $caseInsensitive=false) | |
Static Public Member Functions | |
static | normalizeKeyword ($keyword) |
Public Attributes | |
$parse_error = '' | |
$lastStopKeyWord = '' | |
Protected Member Functions | |
getValueInQuotes (&$parseString, $quote) | |
getValueInQuotesGeneric (&$parseString, $quote) | |
getValueInQuotesMssql (&$parseString, $quote) | |
parseSELECT ($parseString, &$parameterReferences=null) | |
parseUPDATE ($parseString) | |
parseINSERT ($parseString) | |
parseDELETE ($parseString) | |
parseEXPLAIN ($parseString) | |
parseCREATETABLE ($parseString) | |
parseALTERTABLE ($parseString) | |
parseDROPTABLE ($parseString) | |
parseCREATEDATABASE ($parseString) | |
parseTRUNCATETABLE ($parseString) | |
parseCaseStatement (&$parseString) | |
parseCastStatement (&$parseString) | |
nextPart (&$parseString, $regex, $trimAll=false) | |
& | getValueOrParameter (&$parseString, $comparator= '', $mode= '', array &$parameterReferences=array()) |
getValue (&$parseString, $comparator= '', $mode= '') | |
parseStripslashes ($str) | |
parseError ($msg, $restQuery) | |
trimSQL ($str) | |
getSqlCompiler () | |
Protected Attributes | |
$databaseConnection | |
$nativeSqlCompiler | |
$sqlCompiler | |
Static Protected Attributes | |
static | $comparatorPatterns |
static | $interQueryWhitespaces = array(' ', TAB, CR, LF) |
PHP SQL engine / server
Definition at line 22 of file SqlParser.php.
__construct | ( | DatabaseConnection | $databaseConnection = null | ) |
DatabaseConnection | $databaseConnection |
Definition at line 89 of file SqlParser.php.
References SqlParser\$databaseConnection, $GLOBALS, and GeneralUtility\makeInstance().
checkEmptyDefaultValue | ( | $featureIndex | ) |
Checks if the submitted feature index contains a default value definition and the default value
array | $featureIndex | A feature index as produced by parseFieldDef() |
Definition at line 1490 of file SqlParser.php.
compileFieldCfg | ( | $fieldCfg | ) |
Compile field definition
array | $fieldCfg | Field definition parts |
Definition at line 1725 of file SqlParser.php.
References SqlParser\getSqlCompiler().
compileFieldList | ( | $selectFields, | |
$compileComments = true |
|||
) |
Compiles a "SELECT [output] FROM..:" field list based on input array (made with ->parseFieldList()) Can also compile field lists for ORDER BY and GROUP BY.
array | $selectFields | Array of select fields, (made with ->parseFieldList()) |
bool | $compileComments | Whether comments should be compiled |
Definition at line 1702 of file SqlParser.php.
References SqlParser\getSqlCompiler().
Referenced by SqlParser\debug_parseSQLpart().
compileFromTables | ( | $tablesArray | ) |
Compiles a "FROM [output] WHERE..:" table list based on input array (made with ->parseFromTables())
array | $tablesArray | Array of table names, (made with ->parseFromTables()) |
Definition at line 1714 of file SqlParser.php.
References SqlParser\getSqlCompiler().
Referenced by SqlParser\debug_parseSQLpart().
compileSQL | ( | $components | ) |
Compiles an SQL query from components
array | $components | Array of SQL query components |
Definition at line 1688 of file SqlParser.php.
References SqlParser\getSqlCompiler().
Referenced by SqlParser\debug_testSQL().
compileWhereClause | ( | $clauseArray, | |
$functionMapping = true |
|||
) |
Implodes an array of WHERE clause configuration into a WHERE clause.
DBAL-specific: The only(!) handled "calc" operators supported by parseWhereClause() are:
array | $clauseArray | |
bool | $functionMapping |
Definition at line 1746 of file SqlParser.php.
References SqlParser\getSqlCompiler().
Referenced by SqlParser\debug_parseSQLpart().
debug_parseSQLpart | ( | $part, | |
$str | |||
) |
Check parsability of input SQL part string; Will parse and re-compile after which it is compared
string | $part | Part definition of string; "SELECT" = fieldlist (also ORDER BY and GROUP BY), "FROM" = table list, "WHERE" = Where clause. |
string | $str | SQL string to verify parsability of |
Definition at line 1804 of file SqlParser.php.
References SqlParser\compileFieldList(), SqlParser\compileFromTables(), SqlParser\compileWhereClause(), SqlParser\debug_parseSQLpartCompare(), SqlParser\getSqlCompiler(), SqlParser\parseFieldList(), SqlParser\parseFromTables(), and SqlParser\parseWhereClause().
debug_parseSQLpartCompare | ( | $str, | |
$newStr, | |||
$caseInsensitive = false |
|||
) |
Compare two query strings by stripping away whitespace.
string | $str | SQL String 1 |
string | $newStr | SQL string 2 |
bool | $caseInsensitive | If TRUE, the strings are compared insensitive to case |
Definition at line 1829 of file SqlParser.php.
References SqlParser\trimSQL().
Referenced by SqlParser\debug_parseSQLpart(), and SqlParser\debug_testSQL().
debug_testSQL | ( | $SQLquery | ) |
Performs the ultimate test of the parser: Direct a SQL query in; You will get it back (through the parsed and re-compiled) if no problems, otherwise the script will print the error and exit
string | $SQLquery | SQL query |
Definition at line 1774 of file SqlParser.php.
References SqlParser\compileSQL(), debug(), SqlParser\debug_parseSQLpartCompare(), and SqlParser\parseSQL().
|
protected |
Definition at line 1754 of file SqlParser.php.
References SqlParser\$nativeSqlCompiler, and SqlParser\$sqlCompiler.
Referenced by SqlParser\compileFieldCfg(), SqlParser\compileFieldList(), SqlParser\compileFromTables(), SqlParser\compileSQL(), SqlParser\compileWhereClause(), and SqlParser\debug_parseSQLpart().
|
protected |
Finds value in beginning of $parseString, returns result and strips it of parseString
string | $parseString | The parseString, eg. "(0,1,2,3) ..." or "('asdf','qwer') ..." or "1234 ..." or "'My string value here' ... @param string $comparator The comparator used before. If "NOT IN" or "IN" then the value is expected to be a list of values. Otherwise just an integer (un-quoted) or string (quoted) @param string $mode The mode, eg. "INDEX |
Definition at line 1578 of file SqlParser.php.
References SqlParser\getValueInQuotes(), GeneralUtility\inList(), SqlParser\nextPart(), and SqlParser\parseError().
Referenced by SqlParser\getValueOrParameter(), SqlParser\parseALTERTABLE(), SqlParser\parseCaseStatement(), SqlParser\parseCastStatement(), SqlParser\parseCREATETABLE(), SqlParser\parseFieldDef(), SqlParser\parseFromTables(), SqlParser\parseINSERT(), SqlParser\parseUPDATE(), and SqlParser\parseWhereClause().
|
protected |
Gets value in quotes from $parseString.
string | $parseString | String from which to find value in quotes. Notice that $parseString is passed by reference and is shortened by the output of this function. |
string | $quote | The quote used; input either " or ' |
Definition at line 103 of file SqlParser.php.
References SqlParser\getValueInQuotesGeneric(), and SqlParser\getValueInQuotesMssql().
Referenced by SqlParser\getValue().
|
protected |
Get value in quotes from $parseString. NOTICE: If a query being parsed was prepared for another database than MySQL this function should probably be changed
string | $parseString | String from which to find value in quotes. Notice that $parseString is passed by reference and is shortend by the output of this function. |
string | $quote | The quote used; input either " or ' |
Definition at line 127 of file SqlParser.php.
References SqlParser\parseStripslashes().
Referenced by SqlParser\getValueInQuotes().
|
protected |
Gets value in quotes from $parseString. This method targets MSSQL exclusively.
string | $parseString | String from which to find value in quotes. Notice that $parseString is passed by reference and is shortened by the output of this function. |
string | $quote | The quote used; input either " or ' |
Definition at line 151 of file SqlParser.php.
References elseif, and SqlParser\parseStripslashes().
Referenced by SqlParser\getValueInQuotes().
|
protected |
Finds value or either named (:name) or question mark (?) parameter markers at the beginning of $parseString, returns result and strips it of parseString. This method returns a pointer to the parameter or value that was found. In case of a parameter the pointer is a reference to the corresponding item in array $parameterReferences.
string | $parseString | The parseString |
string | $comparator | The comparator used before. |
string | $mode | The mode, e.g., "INDEX |
mixed | The value (string/integer) or parameter (:name/?). Otherwise an array with error message in first key (0) |
Definition at line 1546 of file SqlParser.php.
References elseif, SqlParser\getValue(), and SqlParser\nextPart().
Referenced by SqlParser\parseWhereClause().
|
protected |
Strips off a part of the parseString and returns the matching part. Helper function for the parsing methods.
string | $parseString | Parse string; if $regex finds anything the value of the first () level will be stripped of the string in the beginning. Further $parseString is left-trimmed (on success). Notice; parsestring is passed by reference. |
string | $regex | Regex to find a matching part in the beginning of the string. Rules: You MUST start the regex with "^" (finding stuff in the beginning of string) and the result of the first parenthesis is what will be returned to you (and stripped of the string). Eg. '^(AND|OR|&&)[[:space:]]+' will return AND, OR or && if found and having one of more whitespaces after it, plus shorten $parseString with that match and any space after (by ltrim()) |
bool | $trimAll | If set the full match of the regex is stripped of the beginning of the string! |
Definition at line 1512 of file SqlParser.php.
Referenced by SqlParser\getValue(), SqlParser\getValueOrParameter(), SqlParser\parseALTERTABLE(), SqlParser\parseCaseStatement(), SqlParser\parseCastStatement(), SqlParser\parseCREATEDATABASE(), SqlParser\parseCREATETABLE(), SqlParser\parseDELETE(), SqlParser\parseDROPTABLE(), SqlParser\parseFieldDef(), SqlParser\parseFieldList(), SqlParser\parseFromTables(), SqlParser\parseINSERT(), SqlParser\parseSELECT(), SqlParser\parseSQL(), SqlParser\parseTRUNCATETABLE(), SqlParser\parseUPDATE(), and SqlParser\parseWhereClause().
|
static |
Normalizes the keyword by removing any separator and changing to uppercase
string | $keyword | The keyword being normalized |
Definition at line 1530 of file SqlParser.php.
Referenced by Mysql\compileALTERTABLE(), Mysql\compileWhereClause(), Adodb\compileWhereClause(), SqlParser\parseALTERTABLE(), SqlParser\parseCREATETABLE(), SqlParser\parseFieldDef(), SqlParser\parseFieldList(), SqlParser\parseFromTables(), SqlParser\parseSQL(), and SqlParser\parseWhereClause().
|
protected |
Parsing ALTER TABLE query
string | $parseString | SQL string starting with ALTER TABLE |
Definition at line 637 of file SqlParser.php.
References SqlParser\$parse_error, SqlParser\getValue(), GeneralUtility\inList(), SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseError(), SqlParser\parseFieldDef(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Parsing a CASE ... WHEN flow-control construct. The output from this function can be compiled back with ->compileCaseStatement()
string | $parseString | The string with the CASE ... WHEN construct, eg. "CASE field WHEN 1 THEN 0 ELSE ..." etc. NOTICE: passed by reference! |
Definition at line 944 of file SqlParser.php.
References SqlParser\getValue(), SqlParser\nextPart(), SqlParser\parseError(), and SqlParser\parseWhereClause().
Referenced by SqlParser\parseFieldList().
|
protected |
Parsing a CAST definition in the "JOIN [$parseString] ..." part of a query into an array. The success of this parsing determines if that part of the query is supported by TYPO3.
string | $parseString | JOIN clause to parse. NOTICE: passed by reference! |
Definition at line 979 of file SqlParser.php.
References SqlParser\getValue(), SqlParser\nextPart(), and SqlParser\parseError().
Referenced by SqlParser\parseFromTables().
|
protected |
Parsing CREATE DATABASE query
string | $parseString | SQL string starting with CREATE DATABASE |
Definition at line 752 of file SqlParser.php.
References SqlParser\nextPart(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Parsing CREATE TABLE query
string | $parseString | SQL string starting with CREATE TABLE |
Definition at line 550 of file SqlParser.php.
References SqlParser\$parse_error, elseif, SqlParser\getValue(), SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseError(), SqlParser\parseFieldDef(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Parsing DELETE query
string | $parseString | SQL string with DELETE query to parse |
Definition at line 494 of file SqlParser.php.
References SqlParser\$parse_error, SqlParser\nextPart(), SqlParser\parseError(), SqlParser\parseWhereClause(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Parsing DROP TABLE query
string | $parseString | SQL string starting with DROP TABLE |
Definition at line 723 of file SqlParser.php.
References SqlParser\nextPart(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Setting the internal error message value, $this->parse_error and returns that value.
string | $msg | Input error message |
string | $restQuery | Remaining query to parse. |
Definition at line 1655 of file SqlParser.php.
References SqlParser\$parse_error.
Referenced by SqlParser\getValue(), SqlParser\parseALTERTABLE(), SqlParser\parseCaseStatement(), SqlParser\parseCastStatement(), SqlParser\parseCREATEDATABASE(), SqlParser\parseCREATETABLE(), SqlParser\parseDELETE(), SqlParser\parseDROPTABLE(), SqlParser\parseFieldDef(), SqlParser\parseFieldList(), SqlParser\parseFromTables(), SqlParser\parseINSERT(), SqlParser\parseSELECT(), SqlParser\parseSQL(), SqlParser\parseTRUNCATETABLE(), SqlParser\parseUPDATE(), and SqlParser\parseWhereClause().
|
protected |
Parsing EXPLAIN query
string | $parseString | SQL string with EXPLAIN query to parse |
Definition at line 530 of file SqlParser.php.
References SqlParser\parseSELECT(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
parseFieldDef | ( | & | $parseString, |
$stopRegex = '' |
|||
) |
Parsing the WHERE clause fields in the "WHERE [$parseString] ..." part of a query into a multidimensional array. The success of this parsing determines if that part of the query is supported by TYPO3.
string | $parseString | WHERE clause to parse. NOTICE: passed by reference! |
string | $stopRegex | Regular expressing to STOP parsing, eg. '^(GROUP BY|ORDER BY|LIMIT)([[:space:]]*)' |
Definition at line 1449 of file SqlParser.php.
References SqlParser\getValue(), SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\parseALTERTABLE(), and SqlParser\parseCREATETABLE().
parseFieldList | ( | & | $parseString, |
$stopRegex = '' |
|||
) |
Parsing the fields in the "SELECT [$selectFields] FROM" part of a query into an array. The output from this function can be compiled back into a field list with ->compileFieldList() Will detect the keywords "DESC" and "ASC" after the table name; thus is can be used for parsing the more simply ORDER BY and GROUP BY field lists as well!
string | $parseString | The string with fieldnames, eg. "title, uid AS myUid, max(tstamp), count(*)" etc. NOTICE: passed by reference! |
string | $stopRegex | Regular expressing to STOP parsing, eg. '^(FROM)([[:space:]]*)' |
Definition at line 815 of file SqlParser.php.
References SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseCaseStatement(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\debug_parseSQLpart(), and SqlParser\parseSELECT().
parseFromTables | ( | & | $parseString, |
$stopRegex = '' |
|||
) |
Parsing the tablenames in the "FROM [$parseString] WHERE" part of a query into an array. The success of this parsing determines if that part of the query is supported by TYPO3.
string | $parseString | List of tables, eg. "pages, tt_content" or "pages A, pages B". NOTICE: passed by reference! |
string | $stopRegex | Regular expressing to STOP parsing, eg. '^(WHERE)([[:space:]]*)' |
Definition at line 1016 of file SqlParser.php.
References elseif, SqlParser\getValue(), SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseCastStatement(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\debug_parseSQLpart(), and SqlParser\parseSELECT().
|
protected |
Parsing INSERT query
string | $parseString | SQL string with INSERT query to parse |
Definition at line 403 of file SqlParser.php.
References SqlParser\$parse_error, SqlParser\getValue(), SqlParser\nextPart(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Parsing SELECT query
string | $parseString | SQL string with SELECT query to parse |
array | $parameterReferences | Array holding references to either named (:name) or question mark (?) parameters found |
Definition at line 274 of file SqlParser.php.
References SqlParser\$parse_error, SqlParser\nextPart(), SqlParser\parseError(), SqlParser\parseFieldList(), SqlParser\parseFromTables(), SqlParser\parseWhereClause(), and SqlParser\trimSQL().
Referenced by SqlParser\parseEXPLAIN(), SqlParser\parseSQL(), and SqlParser\parseWhereClause().
parseSQL | ( | $parseString | ) |
Parses any single SQL query
string | $parseString | SQL query |
Definition at line 208 of file SqlParser.php.
References SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseALTERTABLE(), SqlParser\parseCREATEDATABASE(), SqlParser\parseCREATETABLE(), SqlParser\parseDELETE(), SqlParser\parseDROPTABLE(), SqlParser\parseError(), SqlParser\parseEXPLAIN(), SqlParser\parseINSERT(), SqlParser\parseSELECT(), SqlParser\parseTRUNCATETABLE(), SqlParser\parseUPDATE(), and SqlParser\trimSQL().
Referenced by SqlParser\debug_testSQL().
|
protected |
Strip slashes function used for parsing NOTICE: If a query being parsed was prepared for another database than MySQL this function should probably be changed
string | $str | Input string |
Definition at line 1640 of file SqlParser.php.
Referenced by SqlParser\getValueInQuotesGeneric(), and SqlParser\getValueInQuotesMssql().
|
protected |
Parsing TRUNCATE TABLE query
string | $parseString | SQL string starting with TRUNCATE TABLE |
Definition at line 779 of file SqlParser.php.
References SqlParser\nextPart(), SqlParser\parseError(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
|
protected |
Parsing UPDATE query
string | $parseString | SQL string with UPDATE query to parse |
Definition at line 349 of file SqlParser.php.
References SqlParser\$parse_error, SqlParser\getValue(), SqlParser\nextPart(), SqlParser\parseError(), SqlParser\parseWhereClause(), and SqlParser\trimSQL().
Referenced by SqlParser\parseSQL().
parseWhereClause | ( | & | $parseString, |
$stopRegex = '' , |
|||
array & | $parameterReferences = array() |
||
) |
Parsing the WHERE clause fields in the "WHERE [$parseString] ..." part of a query into a multidimensional array. The success of this parsing determines if that part of the query is supported by TYPO3.
string | $parseString | WHERE clause to parse. NOTICE: passed by reference! |
string | $stopRegex | Regular expressing to STOP parsing, eg. '^(GROUP BY|ORDER BY|LIMIT)([[:space:]]*)' |
array | $parameterReferences | Array holding references to either named (:name) or question mark (?) parameters found |
Definition at line 1146 of file SqlParser.php.
References SqlParser\$parse_error, elseif, SqlParser\getValue(), SqlParser\getValueOrParameter(), GeneralUtility\inList(), SqlParser\nextPart(), SqlParser\normalizeKeyword(), SqlParser\parseError(), SqlParser\parseSELECT(), and SqlParser\trimSQL().
Referenced by SqlParser\debug_parseSQLpart(), SqlParser\parseCaseStatement(), SqlParser\parseDELETE(), SqlParser\parseSELECT(), and SqlParser\parseUPDATE().
|
protected |
Trimming SQL as preparation for parsing. ";" in the end is stripped off. White space is trimmed away around the value A single space-char is added in the end
string | $str | Input string |
Definition at line 1670 of file SqlParser.php.
Referenced by SqlParser\debug_parseSQLpartCompare(), SqlParser\parseALTERTABLE(), SqlParser\parseCREATEDATABASE(), SqlParser\parseCREATETABLE(), SqlParser\parseDELETE(), SqlParser\parseDROPTABLE(), SqlParser\parseEXPLAIN(), SqlParser\parseFieldDef(), SqlParser\parseFieldList(), SqlParser\parseFromTables(), SqlParser\parseINSERT(), SqlParser\parseSELECT(), SqlParser\parseSQL(), SqlParser\parseTRUNCATETABLE(), SqlParser\parseUPDATE(), and SqlParser\parseWhereClause().
|
staticprotected |
Definition at line 43 of file SqlParser.php.
|
protected |
Definition at line 73 of file SqlParser.php.
Referenced by SqlParser\__construct().
|
staticprotected |
Definition at line 68 of file SqlParser.php.
$lastStopKeyWord = '' |
Definition at line 36 of file SqlParser.php.
|
protected |
Definition at line 78 of file SqlParser.php.
Referenced by SqlParser\getSqlCompiler().
$parse_error = '' |
Definition at line 29 of file SqlParser.php.
Referenced by SqlParser\parseALTERTABLE(), SqlParser\parseCREATETABLE(), SqlParser\parseDELETE(), SqlParser\parseError(), SqlParser\parseINSERT(), SqlParser\parseSELECT(), SqlParser\parseUPDATE(), and SqlParser\parseWhereClause().
|
protected |
Definition at line 84 of file SqlParser.php.
Referenced by SqlParser\getSqlCompiler().