t3lib_sqlparser Class Reference

Inheritance diagram for t3lib_sqlparser:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 parseSQL ($parseString)
 parseFieldList (&$parseString, $stopRegex= '')
 parseFromTables (&$parseString, $stopRegex= '')
 parseWhereClause (&$parseString, $stopRegex= '')
 parseFieldDef (&$parseString, $stopRegex= '')
 compileSQL ($components)
 compileFieldList ($selectFields, $compileComments=TRUE)
 compileFromTables ($tablesArray)
 compileWhereClause ($clauseArray)
 compileFieldCfg ($fieldCfg)
 debug_parseSQLpart ($part, $str)
 debug_parseSQLpartCompare ($str, $newStr, $caseInsensitive=FALSE)
 debug_testSQL ($SQLquery)

Public Attributes

 $parse_error = ''
 $lastStopKeyWord = ''

Protected Member Functions

 parseSELECT ($parseString)
 parseUPDATE ($parseString)
 parseINSERT ($parseString)
 parseDELETE ($parseString)
 parseEXPLAIN ($parseString)
 parseCREATETABLE ($parseString)
 parseALTERTABLE ($parseString)
 parseDROPTABLE ($parseString)
 parseCREATEDATABASE ($parseString)
 parseTRUNCATETABLE ($parseString)
 parseCaseStatement (&$parseString)
 nextPart (&$parseString, $regex, $trimAll=FALSE)
 getValue (&$parseString, $comparator= '', $mode= '')
 getValueInQuotes (&$parseString, $quote)
 parseStripslashes ($str)
 compileAddslashes ($str)
 parseError ($msg, $restQuery)
 trimSQL ($str)
 compileSELECT ($components)
 compileUPDATE ($components)
 compileINSERT ($components)
 compileDELETE ($components)
 compileCREATETABLE ($components)
 compileALTERTABLE ($components)
 compileTRUNCATETABLE (array $components)
 compileCaseStatement (array $components)

Detailed Description

Definition at line 107 of file class.t3lib_sqlparser.php.


Member Function Documentation

t3lib_sqlparser::compileAddslashes ( str  )  [protected]

Add slashes function used for compiling queries NOTICE: If a query being parsed was prepared for another database than MySQL this function should probably be changed

Parameters:
string Input string
Returns:
string Output string

Reimplemented in ux_t3lib_sqlparser.

Definition at line 1440 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileALTERTABLE ( components  )  [protected]

Compiles an ALTER TABLE statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL ALTER TABLE query
See also:
parseALTERTABLE()

Reimplemented in ux_t3lib_sqlparser.

Definition at line 1691 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileCaseStatement ( array $  components  )  [protected]

Compiles a CASE ... WHEN flow-control construct based on input array (made with ->parseCaseStatement())

Parameters:
array Array of case components, (made with ->parseCaseStatement())
Returns:
string case when string
See also:
parseCaseStatement()

Definition at line 1812 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileCREATETABLE ( components  )  [protected]

Compiles a CREATE TABLE statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL CREATE TABLE query
See also:
parseCREATETABLE()

Reimplemented in ux_t3lib_sqlparser.

Definition at line 1658 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileDELETE ( components  )  [protected]

Compiles an DELETE statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL DELETE query
See also:
parseDELETE()

Definition at line 1638 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileFieldCfg ( fieldCfg  ) 

Compile field definition

Parameters:
array Field definition parts
Returns:
string Field definition string

Reimplemented in ux_t3lib_sqlparser.

Definition at line 1972 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::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.

Parameters:
array Array of select fields, (made with ->parseFieldList())
boolean Whether comments should be compiled
Returns:
string Select field string
See also:
parseFieldList()

Definition at line 1761 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileFromTables ( tablesArray  ) 

Compiles a "FROM [output] WHERE..:" table list based on input array (made with ->parseFromTables())

Parameters:
array Array of table names, (made with ->parseFromTables())
Returns:
string Table name string
See also:
parseFromTables()

Definition at line 1840 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileINSERT ( components  )  [protected]

Compiles an INSERT statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL INSERT query
See also:
parseINSERT()

Reimplemented in ux_t3lib_sqlparser.

Definition at line 1596 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileSELECT ( components  )  [protected]

Compiles a SELECT statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL SELECT query
See also:
parseSELECT()

Definition at line 1537 of file class.t3lib_sqlparser.php.

Referenced by ux_t3lib_sqlparser::compileWhereClause().

t3lib_sqlparser::compileSQL ( components  ) 

Compiles an SQL query from components

Parameters:
array Array of SQL query components
Returns:
string SQL query
See also:
parseSQL()

Definition at line 1496 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileTRUNCATETABLE ( array $  components  )  [protected]

Compiles a TRUNCATE TABLE statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL TRUNCATE TABLE query
See also:
parseTRUNCATETABLE()

Definition at line 1724 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileUPDATE ( components  )  [protected]

Compiles an UPDATE statement from components array

Parameters:
array Array of SQL query components
Returns:
string SQL UPDATE query
See also:
parseUPDATE()

Definition at line 1568 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::compileWhereClause ( clauseArray  ) 

Implodes an array of WHERE clause configuration into a WHERE clause.

Parameters:
array WHERE clause configuration
Returns:
string WHERE clause as string.
See also:
explodeWhereClause()

Definition at line 1886 of file class.t3lib_sqlparser.php.

References t3lib_div::inList().

t3lib_sqlparser::debug_parseSQLpart ( part,
str 
)

Check parsability of input SQL part string; Will parse and re-compile after which it is compared

Parameters:
string Part definition of string; "SELECT" = fieldlist (also ORDER BY and GROUP BY), "FROM" = table list, "WHERE" = Where clause.
string SQL string to verify parsability of
Returns:
mixed Returns array with string 1 and 2 if error, otherwise false

Definition at line 2021 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::debug_parseSQLpartCompare ( str,
newStr,
caseInsensitive = FALSE 
)

Compare two query strins by stripping away whitespace.

Parameters:
string SQL String 1
string SQL string 2
boolean If true, the strings are compared insensitive to case
Returns:
mixed Returns array with string 1 and 2 if error, otherwise false

Definition at line 2046 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::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

Parameters:
string SQL query
Returns:
string Query if all is well, otherwise exit.

Definition at line 2079 of file class.t3lib_sqlparser.php.

References debug(), and exit.

t3lib_sqlparser::getValue ( &$  parseString,
comparator = '',
mode = '' 
) [protected]

Finds value in beginning of $parseString, returns result and strips it of parseString

Parameters:
string The parseString, eg. "(0,1,2,3) ..." or "('asdf','qwer') ..." or "1234 ..." or "'My string value here' ..."
string 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)
string The mode, eg. "INDEX"
Returns:
mixed The value (string/integer). Otherwise an array with error message in first key (0)

Definition at line 1339 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::getValueInQuotes ( &$  parseString,
quote 
) [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

Parameters:
string 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 The quote used; input either " or '
Returns:
string The value, passed through stripslashes() !

Definition at line 1401 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::nextPart ( &$  parseString,
regex,
trimAll = FALSE 
) [protected]

Strips off a part of the parseString and returns the matching part. Helper function for the parsing methods.

Parameters:
string 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 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())
boolean If set the full match of the regex is stripped of the beginning of the string!
Returns:
string The value of the first parenthesis level of the REGEX.

Definition at line 1323 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseALTERTABLE ( parseString  )  [protected]

Parsing ALTER TABLE query

Parameters:
string SQL string starting with ALTER TABLE
Returns:
mixed Returns array with components of ALTER TABLE query on success, otherwise an error message string.
See also:
compileALTERTABLE()

Definition at line 545 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseCaseStatement ( &$  parseString  )  [protected]

Parsing a CASE ... WHEN flow-control construct. The output from this function can be compiled back with ->compileCaseStatement()

Parameters:
string The string with the CASE ... WHEN construct, eg. "CASE field WHEN 1 THEN 0 ELSE ..." etc. NOTICE: passed by reference!
Returns:
array If successful parsing, returns an array, otherwise an error string.
See also:
compileCaseConstruct()

Definition at line 867 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::parseCREATEDATABASE ( parseString  )  [protected]

Parsing CREATE DATABASE query

Parameters:
string SQL string starting with CREATE DATABASE
Returns:
mixed Returns array with components of CREATE DATABASE query on success, otherwise an error message string.

Definition at line 647 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseCREATETABLE ( parseString  )  [protected]

Parsing CREATE TABLE query

Parameters:
string SQL string starting with CREATE TABLE
Returns:
mixed Returns array with components of CREATE TABLE query on success, otherwise an error message string.
See also:
compileCREATETABLE()

Definition at line 466 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseDELETE ( parseString  )  [protected]

Parsing DELETE query

Parameters:
string SQL string with DELETE query to parse
Returns:
mixed Returns array with components of DELETE query on success, otherwise an error message string.
See also:
compileDELETE()

Definition at line 406 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseDROPTABLE ( parseString  )  [protected]

Parsing DROP TABLE query

Parameters:
string SQL string starting with DROP TABLE
Returns:
mixed Returns array with components of DROP TABLE query on success, otherwise an error message string.

Definition at line 614 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseError ( msg,
restQuery 
) [protected]

Setting the internal error message value, $this->parse_error and returns that value.

Parameters:
string Input error message
string Remaining query to parse.
Returns:
string Error message.

Definition at line 1454 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseEXPLAIN ( parseString  )  [protected]

Parsing EXPLAIN query

Parameters:
string SQL string with EXPLAIN query to parse
Returns:
mixed Returns array with components of EXPLAIN query on success, otherwise an error message string.
See also:
parseSELECT()

Definition at line 444 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::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.

Parameters:
string WHERE clause to parse. NOTICE: passed by reference!
string Regular expressing to STOP parsing, eg. '^(GROUP BY|ORDER BY|LIMIT)([[:space:]]*)'
Returns:
mixed If successful parsing, returns an array, otherwise an error string.

Definition at line 1260 of file class.t3lib_sqlparser.php.

Referenced by tx_dbal_sqlengine::processAccordingToConfig(), and t3lib_sqlengine::processAccordingToConfig().

t3lib_sqlparser::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!

Parameters:
string The string with fieldnames, eg. "title, uid AS myUid, max(tstamp), count(*)" etc. NOTICE: passed by reference!
string Regular expressing to STOP parsing, eg. '^(FROM)([[:space:]]*)'
Returns:
array If successful parsing, returns an array, otherwise an error string.
See also:
compileFieldList()

Definition at line 733 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::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.

Parameters:
string list of tables, eg. "pages, tt_content" or "pages A, pages B". NOTICE: passed by reference!
string Regular expressing to STOP parsing, eg. '^(WHERE)([[:space:]]*)'
Returns:
array If successful parsing, returns an array, otherwise an error string.
See also:
compileFromTables()

Definition at line 903 of file class.t3lib_sqlparser.php.

Referenced by tx_dbal_sqlengine::exec_SELECTquery(), and t3lib_sqlengine::exec_SELECTquery().

t3lib_sqlparser::parseINSERT ( parseString  )  [protected]

Parsing INSERT query

Parameters:
string SQL string with INSERT query to parse
Returns:
mixed Returns array with components of INSERT query on success, otherwise an error message string.
See also:
compileINSERT()

Definition at line 322 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseSELECT ( parseString  )  [protected]

Parsing SELECT query

Parameters:
string SQL string with SELECT query to parse
Returns:
mixed Returns array with components of SELECT query on success, otherwise an error message string.
See also:
compileSELECT()

Definition at line 196 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseSQL ( parseString  ) 

Parses any single SQL query

Parameters:
string SQL query
Returns:
array Result array with all the parts in - or error message string
See also:
compileSQL(), debug_testSQL()

Definition at line 129 of file class.t3lib_sqlparser.php.

References nextPart(), parseALTERTABLE(), parseCREATEDATABASE(), parseCREATETABLE(), parseDELETE(), parseDROPTABLE(), parseError(), parseEXPLAIN(), parseINSERT(), parseSELECT(), parseTRUNCATETABLE(), parseUPDATE(), and trimSQL().

Referenced by tx_dbal_handler_xmldb::admin_query(), and tx_dbal_handler_openoffice::admin_query().

t3lib_sqlparser::parseStripslashes ( str  )  [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

Parameters:
string Input string
Returns:
string Output string

Definition at line 1426 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::parseTRUNCATETABLE ( parseString  )  [protected]

Parsing TRUNCATE TABLE query

Parameters:
string SQL string starting with TRUNCATE TABLE
Returns:
mixed Returns array with components of TRUNCATE TABLE query on success, otherwise an error message string.

Definition at line 677 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseUPDATE ( parseString  )  [protected]

Parsing UPDATE query

Parameters:
string SQL string with UPDATE query to parse
Returns:
mixed Returns array with components of UPDATE query on success, otherwise an error message string.
See also:
compileUPDATE()

Definition at line 268 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().

t3lib_sqlparser::parseWhereClause ( &$  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.

Parameters:
string WHERE clause to parse. NOTICE: passed by reference!
string Regular expressing to STOP parsing, eg. '^(GROUP BY|ORDER BY|LIMIT)([[:space:]]*)'
Returns:
mixed If successful parsing, returns an array, otherwise an error string.

Definition at line 1003 of file class.t3lib_sqlparser.php.

Referenced by tx_dbal_sqlengine::exec_DELETEquery(), t3lib_sqlengine::exec_DELETEquery(), tx_dbal_sqlengine::exec_SELECTquery(), t3lib_sqlengine::exec_SELECTquery(), tx_dbal_sqlengine::exec_UPDATEquery(), and t3lib_sqlengine::exec_UPDATEquery().

t3lib_sqlparser::trimSQL ( str  )  [protected]

Trimming SQL as preparation for parsing. ";" in the end is stripped of. White space is trimmed away around the value A single space-char is added in the end

Parameters:
string Input string
Returns:
string Output string

Definition at line 1468 of file class.t3lib_sqlparser.php.

Referenced by parseSQL().


Member Data Documentation

t3lib_sqlparser::$lastStopKeyWord = ''

Definition at line 111 of file class.t3lib_sqlparser.php.

t3lib_sqlparser::$parse_error = ''

Definition at line 110 of file class.t3lib_sqlparser.php.


The documentation for this class was generated from the following file:
Generated on Sat Mar 6 04:18:09 2010 for TYPO3 API by  doxygen 1.4.7