TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Dbal\Database\SqlParser Class Reference
Inheritance diagram for TYPO3\CMS\Dbal\Database\SqlParser:
TYPO3\CMS\Core\Database\SqlParser ux_t3lib_sqlparser

Public Member Functions

 __construct (DatabaseConnection $databaseConnection=NULL)
 
 compileFieldList ($selectFields, $compileComments=TRUE, $functionMapping=TRUE)
 
 compileCREATETABLE ($components)
 
 compileALTERTABLE ($components)
 
 compileFieldCfg ($fieldCfg)
 
 checkEmptyDefaultValue ($featureIndex)
 
 compileWhereClause ($clauseArray, $functionMapping=TRUE)
 
 debug_testSQL ($SQLquery)
 
- Public Member Functions inherited from TYPO3\CMS\Core\Database\SqlParser
 __construct ()
 
 parseSQL ($parseString)
 
 parseFieldList (&$parseString, $stopRegex='')
 
 parseFromTables (&$parseString, $stopRegex='')
 
 parseWhereClause (&$parseString, $stopRegex='', array &$parameterReferences=array())
 
 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)
 

Protected Member Functions

 getValueInQuotes (&$parseString, $quote)
 
 getValueInQuotesMssql (&$parseString, $quote)
 
 compileCaseStatement (array $components, $functionMapping=TRUE)
 
 compileAddslashes ($str)
 
 compileINSERT ($components)
 
- Protected Member Functions inherited from TYPO3\CMS\Core\Database\SqlParser
 parseSELECT ($parseString, &$parameterReferences=NULL)
 
 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)
 
getValueOrParameter (&$parseString, $comparator='', $mode='', array &$parameterReferences=array())
 
 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)
 

Protected Attributes

 $databaseConnection
 

Additional Inherited Members

- Public Attributes inherited from TYPO3\CMS\Core\Database\SqlParser
 $parse_error = ''
 
 $lastStopKeyWord = ''
 

Detailed Description

PHP SQL engine / server

Author
Kasper Skårhøj kaspe.nosp@m.rYYY.nosp@m.Y@typ.nosp@m.o3.c.nosp@m.om
Karsten Dambekalns karst.nosp@m.en@t.nosp@m.ypo3..nosp@m.org
Xavier Perseguers xavie.nosp@m.r@ty.nosp@m.po3.o.nosp@m.rg

Definition at line 25 of file SqlParser.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Dbal\Database\SqlParser::__construct ( DatabaseConnection  $databaseConnection = NULL)
Parameters
DatabaseConnection$databaseConnection

Definition at line 35 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\$databaseConnection, and $GLOBALS.

Member Function Documentation

◆ checkEmptyDefaultValue()

TYPO3\CMS\Dbal\Database\SqlParser::checkEmptyDefaultValue (   $featureIndex)

Checks if the submitted feature index contains a default value definition and the default value

Parameters
array$featureIndexA feature index as produced by parseFieldDef()
Returns
boolean
See also
::parseFieldDef()

Definition at line 442 of file SqlParser.php.

◆ compileAddslashes()

TYPO3\CMS\Dbal\Database\SqlParser::compileAddslashes (   $str)
protected

Add slashes function used for compiling queries This method overrides the method from because the input string is already properly escaped.

Parameters
string$strInput string
Returns
string Output string

Definition at line 214 of file SqlParser.php.

Referenced by TYPO3\CMS\Dbal\Database\SqlParser\compileFieldCfg(), and TYPO3\CMS\Dbal\Database\SqlParser\compileWhereClause().

◆ compileALTERTABLE()

TYPO3\CMS\Dbal\Database\SqlParser::compileALTERTABLE (   $components)

Compiles an ALTER TABLE statement from components array

Parameters
arrayArray of SQL query components
Returns
string SQL ALTER TABLE query
See also
parseALTERTABLE()

Definition at line 320 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\compileFieldCfg().

◆ compileCaseStatement()

TYPO3\CMS\Dbal\Database\SqlParser::compileCaseStatement ( array  $components,
  $functionMapping = TRUE 
)
protected

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

Parameters
array$componentsArray of case components, (made with ->parseCaseStatement())
boolean$functionMappingWhether function mapping should take place
Returns
string case when string
See also
parseCaseStatement()

Definition at line 176 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\compileWhereClause().

Referenced by TYPO3\CMS\Dbal\Database\SqlParser\compileFieldList().

◆ compileCREATETABLE()

TYPO3\CMS\Dbal\Database\SqlParser::compileCREATETABLE (   $components)

Compiles a CREATE TABLE statement from components array

Parameters
array$componentsArray of SQL query components
Returns
array array with SQL CREATE TABLE/INDEX command(s)
See also
parseCREATETABLE()

Definition at line 273 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\compileFieldCfg().

◆ compileFieldCfg()

TYPO3\CMS\Dbal\Database\SqlParser::compileFieldCfg (   $fieldCfg)

Compile field definition

Parameters
array$fieldCfgField definition parts
Returns
string Field definition string

Definition at line 365 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\compileAddslashes().

Referenced by TYPO3\CMS\Dbal\Database\SqlParser\compileALTERTABLE(), and TYPO3\CMS\Dbal\Database\SqlParser\compileCREATETABLE().

◆ compileFieldList()

TYPO3\CMS\Dbal\Database\SqlParser::compileFieldList (   $selectFields,
  $compileComments = TRUE,
  $functionMapping = 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$selectFieldsArray of select fields, (made with ->parseFieldList())
boolean$compileCommentsWhether comments should be compiled
boolean$functionMappingWhether function mapping should take place
Returns
string Select field string
See also
parseFieldList()

Definition at line 123 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\compileCaseStatement().

◆ compileINSERT()

TYPO3\CMS\Dbal\Database\SqlParser::compileINSERT (   $components)
protected

Compiles an INSERT statement from components array

Parameters
arrayArray of SQL query components
Returns
string SQL INSERT query / array
See also
parseINSERT()

Definition at line 237 of file SqlParser.php.

◆ compileWhereClause()

TYPO3\CMS\Dbal\Database\SqlParser::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:

  • the bitwise logical and (&)
  • the addition (+)
  • the substraction (-)
  • the multiplication (*)
  • the division (/)
  • the modulo (%)
Parameters
array$clauseArray
bool$functionMapping
Returns
string WHERE clause as string.
See also
::parseWhereClause()

Definition at line 465 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\compileAddslashes(), TYPO3\CMS\Core\Database\SqlParser\compileSELECT(), TYPO3\CMS\Core\Utility\GeneralUtility\inList(), TYPO3\CMS\Core\Utility\GeneralUtility\isFirstPartOfStr(), and TYPO3\CMS\Core\Utility\GeneralUtility\strtolower().

Referenced by TYPO3\CMS\Dbal\Database\SqlParser\compileCaseStatement().

◆ debug_testSQL()

TYPO3\CMS\Dbal\Database\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$SQLquerySQL query
Returns
string Query if all is well, otherwise exit.

Definition at line 743 of file SqlParser.php.

References TYPO3\CMS\Core\Database\SqlParser\compileSQL(), debug(), TYPO3\CMS\Core\Database\SqlParser\debug_parseSQLpartCompare(), die, and TYPO3\CMS\Core\Database\SqlParser\parseSQL().

◆ getValueInQuotes()

TYPO3\CMS\Dbal\Database\SqlParser::getValueInQuotes ( $parseString,
  $quote 
)
protected

Gets value in quotes from $parseString.

Parameters
string$parseStringString from which to find value in quotes. Notice that $parseString is passed by reference and is shortened by the output of this function.
string$quoteThe quote used; input either " or '
Returns
string The value, passed through parseStripslashes()!

Definition at line 48 of file SqlParser.php.

References TYPO3\CMS\Dbal\Database\SqlParser\getValueInQuotesMssql().

◆ getValueInQuotesMssql()

TYPO3\CMS\Dbal\Database\SqlParser::getValueInQuotesMssql ( $parseString,
  $quote 
)
protected

Gets value in quotes from $parseString. This method targets MSSQL exclusively.

Parameters
string$parseStringString from which to find value in quotes. Notice that $parseString is passed by reference and is shortened by the output of this function.
string$quoteThe quote used; input either " or '
Returns
string

Definition at line 70 of file SqlParser.php.

References TYPO3\CMS\Core\Database\SqlParser\parseStripslashes().

Referenced by TYPO3\CMS\Dbal\Database\SqlParser\getValueInQuotes().

Member Data Documentation

◆ $databaseConnection

TYPO3\CMS\Dbal\Database\SqlParser::$databaseConnection
protected

Definition at line 30 of file SqlParser.php.

Referenced by TYPO3\CMS\Dbal\Database\SqlParser\__construct().