‪TYPO3CMS  10.4
TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend:
TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 injectConfigurationManager (ConfigurationManagerInterface $configurationManager)
 
 injectCacheService (CacheService $cacheService)
 
 injectEnvironmentService (EnvironmentService $environmentService)
 
 injectObjectManager (ObjectManagerInterface $objectManager)
 
 __construct ()
 
int addRow (string $tableName, array $fieldValues, bool $isRelation=false)
 
 updateRow (string $tableName, array $fieldValues, bool $isRelation=false)
 
 updateRelationTableRow (string $tableName, array $fieldValues)
 
 removeRow (string $tableName, array $where, bool $isRelation=false)
 
mixed getMaxValueFromTable (string $tableName, array $where, string $columnName)
 
array bool getRowByIdentifier (string $tableName, array $where)
 
array getObjectDataByQuery (QueryInterface $query)
 
int getObjectCountByQuery (QueryInterface $query)
 
int null getUidOfAlreadyPersistedValueObject (AbstractValueObject $object)
 

Protected Member Functions

array getObjectDataByRawQuery (Statement $statement)
 
array overlayLanguageAndWorkspace (SourceInterface $source, array $rows, QueryInterface $query, int $workspaceUid=null)
 
 overlayLanguageAndWorkspaceForSelect (string $tableName, array $rows, PageRepository $pageRepository, QueryInterface $query)
 
 overlayLanguageAndWorkspaceForJoinedSelect (string $tableName, array $rows, PageRepository $pageRepository, QueryInterface $query)
 
array int mixed null overlayLanguageAndWorkspaceForSingleRecord (string $tableName, array $row, PageRepository $pageRepository, QueryInterface $query)
 
 resolveMovedRecordsInWorkspace (string $tableName, array $rows, int $workspaceUid)
 
 clearPageCache (string $tableName, int $uid)
 
TypoScriptFrontendController null getTSFE ()
 

Protected Attributes

ConnectionPool $connectionPool
 
ConfigurationManagerInterface $configurationManager
 
CacheService $cacheService
 
EnvironmentService $environmentService
 
ObjectManagerInterface $objectManager
 
array $hasPidColumn = array( )
 

Detailed Description

A Storage backend

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 54 of file Typo3DbBackend.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::__construct ( )

Constructor.

Definition at line 118 of file Typo3DbBackend.php.

Member Function Documentation

◆ addRow()

int TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::addRow ( string  $tableName,
array  $fieldValues,
bool  $isRelation = false 
)

Adds a row to the storage

Parameters
string$tableName‪The database table name
array$fieldValues‪The row to be inserted
bool$isRelation‪TRUE if we are currently inserting into a relation table, FALSE by default
Returns
‪int The uid of the inserted row
Exceptions
SqlErrorException

Implements TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface.

Definition at line 132 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\clearPageCache().

◆ clearPageCache()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::clearPageCache ( string  $tableName,
int  $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$tableName‪Table name of the record
int$uid‪UID of the record

Definition at line 725 of file Typo3DbBackend.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK, TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\getTSFE(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\addRow(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\removeRow(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\updateRow().

◆ getMaxValueFromTable()

mixed TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getMaxValueFromTable ( string  $tableName,
array  $where,
string  $columnName 
)

Fetches maximal value for given table column from database.

Parameters
string$tableName‪The database table name
array$where‪An array of where array('fieldname' => value).
string$columnName‪column name to get the max value from
Returns
‪mixed the max value
Exceptions
SqlErrorException

Implements TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface.

Definition at line 275 of file Typo3DbBackend.php.

◆ getObjectCountByQuery()

int TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getObjectCountByQuery ( QueryInterface  $query)

◆ getObjectDataByQuery()

◆ getObjectDataByRawQuery()

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getObjectDataByRawQuery ( Statement  $statement)
protected

Returns the object data using a custom statement

Parameters
Qom\Statement$statement
Returns
‪array
Exceptions
SqlErrorException‪when the raw SQL statement fails in the database

Definition at line 388 of file Typo3DbBackend.php.

References TYPO3\CMS\Core\Database\ConnectionPool\DEFAULT_CONNECTION_NAME, TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement\getBoundVariables(), and TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement\getStatement().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\getObjectDataByQuery().

◆ getRowByIdentifier()

array bool TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getRowByIdentifier ( string  $tableName,
array  $where 
)

Fetches row data from the database

Parameters
string$tableName
array$where‪An array of where array('fieldname' => value).
Returns
‪array|bool
Exceptions
SqlErrorException

Definition at line 307 of file Typo3DbBackend.php.

◆ getTSFE()

TypoScriptFrontendController null TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getTSFE ( )
protected
Returns
‪TypoScriptFrontendController|null

Definition at line 789 of file Typo3DbBackend.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\clearPageCache().

◆ getUidOfAlreadyPersistedValueObject()

int null TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::getUidOfAlreadyPersistedValueObject ( AbstractValueObject  $object)

Checks if a Value Object equal to the given Object exists in the database

Parameters
AbstractValueObject$object‪The Value Object
Returns
‪int|null The matching uid if an object was found, else FALSE
Exceptions
SqlErrorException

Implements TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface.

Definition at line 486 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject\_getProperties().

◆ injectCacheService()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::injectCacheService ( CacheService  $cacheService)
Parameters
CacheService$cacheService

Definition at line 94 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\$cacheService.

◆ injectConfigurationManager()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::injectConfigurationManager ( ConfigurationManagerInterface  $configurationManager)
Parameters
ConfigurationManagerInterface$configurationManager

Definition at line 86 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\$configurationManager.

◆ injectEnvironmentService()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::injectEnvironmentService ( EnvironmentService  $environmentService)
Parameters
EnvironmentService$environmentService

Definition at line 102 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\$environmentService.

◆ injectObjectManager()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::injectObjectManager ( ObjectManagerInterface  $objectManager)
Parameters
ObjectManagerInterface$objectManager

Definition at line 110 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\$objectManager.

◆ overlayLanguageAndWorkspace()

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::overlayLanguageAndWorkspace ( SourceInterface  $source,
array  $rows,
QueryInterface  $query,
int  $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$source‪The source (selector or join)
array$rows
QueryInterface$query
int | null$workspaceUid
Returns
‪array
Exceptions

Definition at line 541 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspaceForJoinedSelect(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspaceForSelect(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\resolveMovedRecordsInWorkspace().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\getObjectDataByQuery().

◆ overlayLanguageAndWorkspaceForJoinedSelect()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::overlayLanguageAndWorkspaceForJoinedSelect ( string  $tableName,
array  $rows,
PageRepository  $pageRepository,
QueryInterface  $query 
)
protected

If the result consists of a JOIN (usually happens if a property is a relation with a MM table) then it is necessary to only do overlays for the fields that are contained in the main database table, otherwise a SQL error is thrown. In order to make this happen, a single SQL query is made to fetch all possible field names (= array keys) of a record (TCA[$tableName][columns] does not contain all needed information), which is then used to compute a separate subset of the row which can be overlaid properly.

Definition at line 596 of file Typo3DbBackend.php.

References TYPO3\CMS\Core\Domain\Repository\PageRepository\getRawRecord(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspaceForSingleRecord().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspace().

◆ overlayLanguageAndWorkspaceForSelect()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::overlayLanguageAndWorkspaceForSelect ( string  $tableName,
array  $rows,
PageRepository  $pageRepository,
QueryInterface  $query 
)
protected

If the result is a plain SELECT (no JOIN) then the regular overlay process works for tables

  • ‪overlay workspace
  • ‪overlay language of versioned record again

Definition at line 577 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspaceForSingleRecord().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspace().

◆ overlayLanguageAndWorkspaceForSingleRecord()

array int mixed null TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::overlayLanguageAndWorkspaceForSingleRecord ( string  $tableName,
array  $row,
PageRepository  $pageRepository,
QueryInterface  $query 
)
protected

◆ removeRow()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::removeRow ( string  $tableName,
array  $where,
bool  $isRelation = false 
)

Deletes a row in the storage

Parameters
string$tableName‪The database table name
array$where‪An array of where array('fieldname' => value).
bool$isRelation‪TRUE if we are currently manipulating a relation table, FALSE by default
Exceptions
SqlErrorException

Implements TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface.

Definition at line 253 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\clearPageCache().

◆ resolveMovedRecordsInWorkspace()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::resolveMovedRecordsInWorkspace ( string  $tableName,
array  $rows,
int  $workspaceUid 
)
protected

Fetches the moved record in case it is supported by the table and if there's only one row in the result set (applying this to all rows does not work, since the sorting order would be destroyed and possible limits are not met anymore) The move pointers are later unset (see versionOL() last argument)

Definition at line 685 of file Typo3DbBackend.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Core\Versioning\VersionState\MOVE_PLACEHOLDER.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\overlayLanguageAndWorkspace().

◆ updateRelationTableRow()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::updateRelationTableRow ( string  $tableName,
array  $fieldValues 
)

Updates a relation row in the storage.

Parameters
string$tableName‪The database relation table name
array$fieldValues‪The row to be updated
Exceptions
SqlErrorException

Implements TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface.

Definition at line 214 of file Typo3DbBackend.php.

◆ updateRow()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::updateRow ( string  $tableName,
array  $fieldValues,
bool  $isRelation = false 
)

Updates a row in the storage

Parameters
string$tableName‪The database table name
array$fieldValues‪The row to be updated
bool$isRelation‪TRUE if we are currently inserting into a relation table, FALSE by default
Exceptions

Implements TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface.

Definition at line 173 of file Typo3DbBackend.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend\clearPageCache().

Member Data Documentation

◆ $cacheService

CacheService TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::$cacheService
protected

◆ $configurationManager

ConfigurationManagerInterface TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::$configurationManager
protected

◆ $connectionPool

ConnectionPool TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::$connectionPool
protected

Definition at line 58 of file Typo3DbBackend.php.

◆ $environmentService

EnvironmentService TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::$environmentService
protected

◆ $hasPidColumn

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::$hasPidColumn = array( )
protected

As determining the table columns is a costly operation this is done only once per table during runtime and cached then

See also
clearPageCache()

Definition at line 81 of file Typo3DbBackend.php.

◆ $objectManager

ObjectManagerInterface TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::$objectManager
protected