Typo3DbBackend

readonly class \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend

Implements
BackendInterface, SingletonInterface

A Storage backend

Table of Contents

Interfaces

BackendInterface
Storage backend interface
SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$autoTagging  : bool
$cacheLifetimeCalculator  : CacheLifetimeCalculator
$cacheService  : CacheService
$connectionPool  : ConnectionPool
$eventDispatcher  : EventDispatcherInterface
$reflectionService  : ReflectionService

Methods

__construct()  : mixed
addRow()  : int
Adds a row to the storage
getObjectCountByQuery()  : int
Returns the number of tuples matching the query.
getObjectDataByQuery()  : array
Returns the object data matching the $query.
getUidOfAlreadyPersistedValueObject()  : int|null
Checks if a Value Object equal to the given Object exists in the database
removeRow()  : void
Deletes a row in the storage
updateRelationTableRow()  : void
Updates a relation row in the storage.
updateRow()  : void
Updates a row in the storage
addCacheTagsForRows()  : void
getObjectDataByRawQuery()  : array
Returns the object data using a custom statement
overlayLanguageAndWorkspace()  : array
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.
overlayLanguageAndWorkspaceForJoinedSelect()  : array
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.
overlayLanguageAndWorkspaceForSelect()  : array
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
overlayLanguageAndWorkspaceForSingleRecord()  : array|int|mixed|null
Takes one specific row, as defined in TCA and does all overlays.
resolveMovedRecordsInWorkspace()  : array
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)

Properties

$autoTagging

protected bool $autoTagging

Attributes

#[Autowire]
$expression: 'service("features").isFeatureEnabled("frontend.cache.autoTagging")'

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

Methods

addRow()

Adds a row to the storage

public addRow(string $tableName, array $fieldValues[, bool $isRelation = false ]) : int

Parameters

$tableName : string

The database table name

$fieldValues : array

The row to be inserted

$isRelation : bool = false

TRUE if we are currently inserting into a relation table, FALSE by default

Tags

throws
SqlErrorException

Return values

int —

The uid of the inserted row

getUidOfAlreadyPersistedValueObject()

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

public getUidOfAlreadyPersistedValueObject(AbstractValueObject $object) : int|null

Parameters

$object : AbstractValueObject

The Value Object

Tags

throws
SqlErrorException

Return values

int|null —

The matching uid if an object was found, else FALSE

removeRow()

Deletes a row in the storage

public removeRow(string $tableName, array $where[, bool $isRelation = false ]) : void

Parameters

$tableName : string

The database table name

$where : array

An array of where array('fieldname' => value).

$isRelation : bool = false

TRUE if we are currently manipulating a relation table, FALSE by default

Tags

throws
SqlErrorException

updateRelationTableRow()

Updates a relation row in the storage.

public updateRelationTableRow(string $tableName, array $fieldValues) : void

Parameters

$tableName : string

The database relation table name

$fieldValues : array

The row to be updated

Tags

throws
SqlErrorException
throws
InvalidArgumentException

updateRow()

Updates a row in the storage

public updateRow(string $tableName, array $fieldValues[, bool $isRelation = false ]) : void

Parameters

$tableName : string

The database table name

$fieldValues : array

The row to be updated

$isRelation : bool = false

TRUE if we are currently inserting into a relation table, FALSE by default

Tags

throws
InvalidArgumentException
throws
SqlErrorException

addCacheTagsForRows()

protected addCacheTagsForRows(string $tableName, array $rows) : void

Parameters

$tableName : string
$rows : array

getObjectDataByRawQuery()

Returns the object data using a custom statement

protected getObjectDataByRawQuery(Statement $statement) : array

Parameters

$statement : Statement

Tags

throws
SqlErrorException

when the raw SQL statement fails in the database

Return values

array

overlayLanguageAndWorkspace()

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.

protected overlayLanguageAndWorkspace(SourceInterface $source, array $rows, QueryInterface $query, Context $context) : array

Parameters

$source : SourceInterface
$rows : array
$query : QueryInterface
$context : Context

Return values

array

overlayLanguageAndWorkspaceForJoinedSelect()

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.

protected overlayLanguageAndWorkspaceForJoinedSelect(string $tableName, array $rows, PageRepository $pageRepository, QueryInterface $query, Context $context) : array

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.

Parameters

$tableName : string
$rows : array
$pageRepository : PageRepository
$query : QueryInterface
$context : Context

Return values

array

overlayLanguageAndWorkspaceForSelect()

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

protected overlayLanguageAndWorkspaceForSelect(string $tableName, array $rows, PageRepository $pageRepository, QueryInterface $query, Context $context) : array

Parameters

$tableName : string
$rows : array
$pageRepository : PageRepository
$query : QueryInterface
$context : Context

Return values

array

overlayLanguageAndWorkspaceForSingleRecord()

Takes one specific row, as defined in TCA and does all overlays.

protected overlayLanguageAndWorkspaceForSingleRecord(string $tableName, array $row, PageRepository $pageRepository, QueryInterface $query) : array|int|mixed|null

Parameters

$tableName : string
$row : array
$pageRepository : PageRepository
$query : QueryInterface

Return values

array|int|mixed|null —

the overlaid row or false or null if overlay failed.

resolveMovedRecordsInWorkspace()

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)

protected resolveMovedRecordsInWorkspace(string $tableName, array $rows, int $workspaceUid) : array

Parameters

$tableName : string
$rows : array
$workspaceUid : int

Return values

array
On this page