TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Typo3DbBackend Class Reference
Inheritance diagram for Typo3DbBackend:
BackendInterface SingletonInterface

Public Member Functions

 injectDataMapper (\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)
 
 injectConfigurationManager (\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
 
 injectCacheService (\TYPO3\CMS\Extbase\Service\CacheService $cacheService)
 
 injectCacheManager (\TYPO3\CMS\Core\Cache\CacheManager $cacheManager)
 
 injectEnvironmentService (\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
 
 injectQueryParser (\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser $queryParser)
 
 __construct ()
 
 initializeObject ()
 
 addRow ($tableName, array $fieldValues, $isRelation=false)
 
 updateRow ($tableName, array $fieldValues, $isRelation=false)
 
 updateRelationTableRow ($tableName, array $fieldValues)
 
 removeRow ($tableName, array $where, $isRelation=false)
 
 getMaxValueFromTable ($tableName, array $where, $columnName)
 
 getRowByIdentifier ($tableName, array $where)
 
 getObjectDataByQuery (QueryInterface $query)
 
 getObjectCountByQuery (QueryInterface $query)
 
 quoteTextValueCallback ($value, $parameters)
 
 getUidOfAlreadyPersistedValueObject (\TYPO3\CMS\Extbase\DomainObject\AbstractValueObject $object)
 
- Public Member Functions inherited from BackendInterface
 getObjectCountByQuery (\TYPO3\CMS\Extbase\Persistence\QueryInterface $query)
 
 getObjectDataByQuery (\TYPO3\CMS\Extbase\Persistence\QueryInterface $query)
 

Protected Member Functions

 resolveWhereStatement (array $where, $tableName= 'foo')
 
 createQueryCommandParametersFromStatementParts (array $statementParts)
 
 getRowsByStatementParts (QueryInterface $query)
 
 getRowsFromDatabase (array $statementParts)
 
 getRowsFromPreparedDatabase (array $statementParts, array $parameters)
 
 getObjectDataByRawQuery (Qom\Statement $statement)
 
 getStatementParts ($query, $resolveParameterPlaceholders=true)
 
 resolveParameterPlaceholders (array $statementParts, array $parameters)
 
 replacePlaceholders (&$sqlString, array $parameters, $tableName= 'foo')
 
 addVisibilityConstraintStatement (\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings, $tableName, array &$sql)
 
 getFrontendConstraintStatement ($tableName, $ignoreEnableFields, array $enableFieldsToBeIgnored=array(), $includeDeleted)
 
 getBackendConstraintStatement ($tableName, $ignoreEnableFields, $includeDeleted)
 
 doLanguageAndWorkspaceOverlay (Qom\SourceInterface $source, array $rows,\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings, $workspaceUid=null)
 
 getPageRepository ()
 
 checkSqlErrors ($sql= '')
 
 clearPageCache ($tableName, $uid)
 
 getQueryCacheEntry ($entryIdentifier)
 
 setQueryCacheEntry ($entryIdentifier, $variable)
 

Protected Attributes

 $databaseHandle
 
 $dataMapper
 
 $pageRepository
 
 $pageTSConfigCache = array()
 
 $configurationManager
 
 $cacheService
 
 $cacheManager
 
 $tableColumnCache
 
 $queryCache
 
 $environmentService
 
 $queryParser
 
 $queryRuntimeCache = array()
 

Detailed Description

A Storage backend

Definition at line 24 of file Typo3DbBackend.php.

Constructor & Destructor Documentation

__construct ( )

Constructor. takes the database handle from $GLOBALS['TYPO3_DB']

Definition at line 145 of file Typo3DbBackend.php.

References $GLOBALS.

Member Function Documentation

addRow (   $tableName,
array  $fieldValues,
  $isRelation = false 
)

Adds a row to the storage

Parameters
string$tableNameThe database table name
array$fieldValuesThe row to be inserted
bool$isRelationTRUE if we are currently inserting into a relation table, FALSE by default
Returns
int The uid of the inserted row

Implements BackendInterface.

Definition at line 169 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\clearPageCache().

addVisibilityConstraintStatement ( \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface  $querySettings,
  $tableName,
array &  $sql 
)
protected

Adds enableFields and deletedClause to the query if necessary

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface$querySettings
string$tableNameThe database table name
array&$sqlThe query parts
Returns
void
Todo:
remove after getUidOfAlreadyPersistedValueObject is adjusted, this was moved to queryParser

Definition at line 689 of file Typo3DbBackend.php.

References $GLOBALS, Typo3DbBackend\getBackendConstraintStatement(), and Typo3DbBackend\getFrontendConstraintStatement().

Referenced by Typo3DbBackend\getUidOfAlreadyPersistedValueObject().

checkSqlErrors (   $sql = '')
protected

Checks if there are SQL errors in the last query, and if yes, throw an exception.

Returns
void
Parameters
string$sqlThe SQL statement
Exceptions
\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException

Definition at line 873 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\addRow(), Typo3DbBackend\getMaxValueFromTable(), Typo3DbBackend\getObjectCountByQuery(), Typo3DbBackend\getObjectDataByRawQuery(), Typo3DbBackend\getRowByIdentifier(), Typo3DbBackend\getRowsFromDatabase(), Typo3DbBackend\getUidOfAlreadyPersistedValueObject(), Typo3DbBackend\removeRow(), Typo3DbBackend\updateRelationTableRow(), and Typo3DbBackend\updateRow().

clearPageCache (   $tableName,
  $uid 
)
protected

Clear the TYPO3 page cache for the given record. If the record lies on a page, then we clear the cache of this page. If the record has no PID column, we clear the cache of the current page as best-effort.

Much of this functionality is taken from DataHandler::clear_cache() which unfortunately only works with logged-in BE user.

Parameters
string$tableNameTable name of the record
int$uidUID of the record
Returns
void

Definition at line 893 of file Typo3DbBackend.php.

References $GLOBALS, elseif, and BackendUtility\getPagesTSconfig().

Referenced by Typo3DbBackend\addRow(), Typo3DbBackend\removeRow(), and Typo3DbBackend\updateRow().

createQueryCommandParametersFromStatementParts ( array  $statementParts)
protected

Creates the parameters for the query methods of the database methods in the TYPO3 core, from an array that came from a parsed query.

Parameters
array$statementParts
Returns
array

Definition at line 363 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\getObjectCountByQuery(), Typo3DbBackend\getRowsFromDatabase(), and Typo3DbBackend\getRowsFromPreparedDatabase().

doLanguageAndWorkspaceOverlay ( Qom\SourceInterface  $source,
array  $rows,
\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface  $querySettings,
  $workspaceUid = null 
)
protected

Performs workspace and language overlay on the given row array. The language and workspace id is automatically detected (depending on FE or BE context). You can also explicitly set the language/workspace id.

Parameters
Qom\SourceInterface$sourceThe source (selector od join)
array$rows
\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface$querySettingsThe TYPO3 CMS specific query settings
null | int$workspaceUid
Returns
array

Definition at line 769 of file Typo3DbBackend.php.

References $GLOBALS, Typo3DbBackend\$pageRepository, elseif, Typo3DbBackend\getPageRepository(), and BackendUtility\isTableWorkspaceEnabled().

Referenced by Typo3DbBackend\getObjectDataByQuery().

getBackendConstraintStatement (   $tableName,
  $ignoreEnableFields,
  $includeDeleted 
)
protected

Returns constraint statement for backend context

Parameters
string$tableName
bool$ignoreEnableFieldsA flag indicating whether the enable fields should be ignored
bool$includeDeletedA flag indicating whether deleted records should be included
Returns
string
Todo:
remove after getUidOfAlreadyPersistedValueObject is adjusted, this was moved to queryParser

Definition at line 747 of file Typo3DbBackend.php.

References BackendUtility\BEenableFields(), and BackendUtility\deleteClause().

Referenced by Typo3DbBackend\addVisibilityConstraintStatement().

getFrontendConstraintStatement (   $tableName,
  $ignoreEnableFields,
array  $enableFieldsToBeIgnored = array(),
  $includeDeleted 
)
protected

Returns constraint statement for frontend context

Parameters
string$tableName
bool$ignoreEnableFieldsA flag indicating whether the enable fields should be ignored
array$enableFieldsToBeIgnoredIf $ignoreEnableFields is true, this array specifies enable fields to be ignored. If it is NULL or an empty array (default) all enable fields are ignored.
bool$includeDeletedA flag indicating whether deleted records should be included
Returns
string
Exceptions
\TYPO3\CMS\Extbase\Persistence\Generic\Exception\InconsistentQuerySettingsException
Todo:
remove after getUidOfAlreadyPersistedValueObject is adjusted, this was moved to queryParser

Definition at line 720 of file Typo3DbBackend.php.

References elseif, and Typo3DbBackend\getPageRepository().

Referenced by Typo3DbBackend\addVisibilityConstraintStatement().

getMaxValueFromTable (   $tableName,
array  $where,
  $columnName 
)

Fetches maximal value for given table column from database.

Parameters
string$tableNameThe database table name
array$whereAn array of where array('fieldname' => value).
string$columnNamecolumn name to get the max value from
Returns
mixed the max value

Implements BackendInterface.

Definition at line 284 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\resolveWhereStatement().

getObjectCountByQuery ( QueryInterface  $query)

Returns the number of tuples matching the query.

Parameters
QueryInterface$query
Exceptions
Exception\BadConstraintException
Returns
int The number of matching tuples

Definition at line 485 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), Typo3DbBackend\createQueryCommandParametersFromStatementParts(), QueryInterface\getConstraint(), and Typo3DbBackend\getStatementParts().

getObjectDataByQuery ( QueryInterface  $query)
getObjectDataByRawQuery ( Qom\Statement  $statement)
protected

Returns the object data using a custom statement

Parameters
Qom\Statement$statement
Returns
array

Definition at line 452 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors().

Referenced by Typo3DbBackend\getObjectDataByQuery().

getPageRepository ( )
protected
getQueryCacheEntry (   $entryIdentifier)
protected

Finds and returns a variable value from the query cache.

Parameters
string$entryIdentifierIdentifier of the cache entry to fetch
Returns
mixed The value

Definition at line 942 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\getStatementParts().

getRowByIdentifier (   $tableName,
array  $where 
)

Fetches row data from the database

Parameters
string$tableName
array$whereAn array of where array('fieldname' => value).
Returns
array|bool

Definition at line 306 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\resolveWhereStatement().

getRowsByStatementParts ( QueryInterface  $query)
protected

Determines whether to use prepared statement or not and returns the rows from the corresponding method

Parameters
QueryInterface$query
Returns
array

Definition at line 385 of file Typo3DbBackend.php.

References QueryInterface\getQuerySettings(), Typo3DbBackend\getRowsFromDatabase(), Typo3DbBackend\getRowsFromPreparedDatabase(), and Typo3DbBackend\getStatementParts().

Referenced by Typo3DbBackend\getObjectDataByQuery().

getRowsFromDatabase ( array  $statementParts)
protected

Fetches the rows directly from the database, not using prepared statement

Parameters
array$statementParts
Returns
array the result

Definition at line 404 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\createQueryCommandParametersFromStatementParts().

Referenced by Typo3DbBackend\getRowsByStatementParts().

getRowsFromPreparedDatabase ( array  $statementParts,
array  $parameters 
)
protected

Fetches the rows from the database, using prepared statement

Parameters
array$statementParts
array$parameters
Returns
array the result

Definition at line 427 of file Typo3DbBackend.php.

References Typo3DbBackend\createQueryCommandParametersFromStatementParts().

Referenced by Typo3DbBackend\getRowsByStatementParts().

getStatementParts (   $query,
  $resolveParameterPlaceholders = true 
)
protected

Looks for the query in cache or builds it up otherwise

Parameters
QueryInterface$query
bool$resolveParameterPlaceholderswhether to resolve the parameters or leave the placeholders
Returns
array
Exceptions
\RuntimeException

The queryParser will preparse the query to get the query's hash and parameters. If the hash is found in the cache and useQueryCaching is enabled, extbase will then take the string representation from cache and build a prepared query with the parameters found.

Otherwise extbase will parse the complete query, build the string representation and run a usual query.

Definition at line 525 of file Typo3DbBackend.php.

References Typo3DbBackend\getQueryCacheEntry(), Typo3DbBackend\resolveParameterPlaceholders(), and Typo3DbBackend\setQueryCacheEntry().

Referenced by Typo3DbBackend\getObjectCountByQuery(), and Typo3DbBackend\getRowsByStatementParts().

getUidOfAlreadyPersistedValueObject ( \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject  $object)

Checks if a Value Object equal to the given Object exists in the data base

Parameters
\TYPO3\CMS\Extbase\DomainObject\AbstractValueObject$objectThe Value Object
Returns
mixed The matching uid if an object was found, else FALSE
Todo:
this is the last monster in this persistence series. refactor!

Implements BackendInterface.

Definition at line 603 of file Typo3DbBackend.php.

References Typo3DbBackend\addVisibilityConstraintStatement(), Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\replacePlaceholders().

initializeObject ( )

Lifecycle method

Returns
void

Definition at line 155 of file Typo3DbBackend.php.

injectCacheManager ( \TYPO3\CMS\Core\Cache\CacheManager  $cacheManager)
Parameters
\TYPO3\CMS\Core\Cache\CacheManager$cacheManager

Definition at line 121 of file Typo3DbBackend.php.

References Typo3DbBackend\$cacheManager.

injectCacheService ( \TYPO3\CMS\Extbase\Service\CacheService  $cacheService)
Parameters
\TYPO3\CMS\Extbase\Service\CacheService$cacheService

Definition at line 113 of file Typo3DbBackend.php.

References Typo3DbBackend\$cacheService.

injectConfigurationManager ( \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface  $configurationManager)
Parameters
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface$configurationManager

Definition at line 105 of file Typo3DbBackend.php.

References Typo3DbBackend\$configurationManager.

injectDataMapper ( \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper  $dataMapper)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper$dataMapper

Definition at line 97 of file Typo3DbBackend.php.

References Typo3DbBackend\$dataMapper.

injectEnvironmentService ( \TYPO3\CMS\Extbase\Service\EnvironmentService  $environmentService)
Parameters
\TYPO3\CMS\Extbase\Service\EnvironmentService$environmentService

Definition at line 129 of file Typo3DbBackend.php.

References Typo3DbBackend\$environmentService.

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser$queryParser

Definition at line 137 of file Typo3DbBackend.php.

References Typo3DbBackend\$queryParser.

quoteTextValueCallback (   $value,
  $parameters 
)

Will be called by the data mapper to quote string values.

Parameters
string$valueThe value to be quoted.
array$parametersAdditional parameters array currently containing the "tablename" key.
Returns
string The quoted string.

Definition at line 591 of file Typo3DbBackend.php.

removeRow (   $tableName,
array  $where,
  $isRelation = false 
)

Deletes a row in the storage

Parameters
string$tableNameThe database table name
array$whereAn array of where array('fieldname' => value).
bool$isRelationTRUE if we are currently manipulating a relation table, FALSE by default
Returns
bool

Implements BackendInterface.

Definition at line 261 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), Typo3DbBackend\clearPageCache(), and Typo3DbBackend\resolveWhereStatement().

replacePlaceholders ( $sqlString,
array  $parameters,
  $tableName = 'foo' 
)
protected

Replace query placeholders in a query part by the given parameters.

Parameters
string&$sqlStringThe query part with placeholders
array$parametersThe parameters
string$tableName
Exceptions
\TYPO3\CMS\Extbase\Persistence\Generic\Exception
Deprecated:
since 6.2, will be removed two versions later
Todo:
add deprecation notice after getUidOfAlreadyPersistedValueObject is adjusted

Definition at line 653 of file Typo3DbBackend.php.

References elseif.

Referenced by Typo3DbBackend\getUidOfAlreadyPersistedValueObject().

resolveParameterPlaceholders ( array  $statementParts,
array  $parameters 
)
protected

Replaces the parameters in the queryStructure with given values

Parameters
array$statementParts
array$parameters
Returns
array

Definition at line 572 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\getStatementParts().

resolveWhereStatement ( array  $where,
  $tableName = 'foo' 
)
protected

Converts an array to an AND concatenated where statement

Parameters
array$wherearray('fieldName' => 'fieldValue')
string$tableNametable to use for escaping config
Returns
string

Definition at line 326 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\getMaxValueFromTable(), Typo3DbBackend\getRowByIdentifier(), Typo3DbBackend\removeRow(), and Typo3DbBackend\updateRelationTableRow().

setQueryCacheEntry (   $entryIdentifier,
  $variable 
)
protected

Saves the value of a PHP variable in the query cache.

Parameters
string$entryIdentifierAn identifier used for this cache entry
mixed$variableThe query to cache
Returns
void

Definition at line 957 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\getStatementParts().

updateRelationTableRow (   $tableName,
array  $fieldValues 
)

Updates a relation row in the storage.

Parameters
string$tableNameThe database relation table name
array$fieldValuesThe row to be updated
Exceptions
\InvalidArgumentException
Returns
bool

Implements BackendInterface.

Definition at line 221 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\resolveWhereStatement().

updateRow (   $tableName,
array  $fieldValues,
  $isRelation = false 
)

Updates a row in the storage

Parameters
string$tableNameThe database table name
array$fieldValuesThe row to be updated
bool$isRelationTRUE if we are currently inserting into a relation table, FALSE by default
Exceptions
\InvalidArgumentException
Returns
bool

Implements BackendInterface.

Definition at line 194 of file Typo3DbBackend.php.

References Typo3DbBackend\checkSqlErrors(), and Typo3DbBackend\clearPageCache().

Member Data Documentation

$cacheManager
protected

Definition at line 65 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\injectCacheManager().

$cacheService
protected

Definition at line 60 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\injectCacheService().

$configurationManager
protected

Definition at line 55 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\injectConfigurationManager().

$databaseHandle
protected

Definition at line 31 of file Typo3DbBackend.php.

$dataMapper
protected

Definition at line 36 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\injectDataMapper().

$environmentService
protected

Definition at line 80 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\injectEnvironmentService().

$pageRepository
protected
$pageTSConfigCache = array()
protected

Definition at line 50 of file Typo3DbBackend.php.

$queryCache
protected

Definition at line 75 of file Typo3DbBackend.php.

$queryParser
protected

Definition at line 85 of file Typo3DbBackend.php.

Referenced by Typo3DbBackend\injectQueryParser().

$queryRuntimeCache = array()
protected

Definition at line 92 of file Typo3DbBackend.php.

$tableColumnCache
protected

Definition at line 70 of file Typo3DbBackend.php.