‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Database\Query\QueryHelper Class Reference

Static Public Member Functions

static array array[] parseOrderBy (string $input)
 
static array array[] parseTableList (string $input)
 
static array string[] parseGroupBy (string $input)
 
static array parseJoin (string $input)
 
static string stripLogicalOperatorPrefix (string $constraint)
 
static array getDateTimeFormats ()
 
static array getDateTimeTypes ()
 
static quoteDatabaseIdentifiers (Connection $connection, string $sql)
 

Detailed Description

Contains misc helper methods to build syntactically valid SQL queries. Most helper functions are required to deal with legacy data where the format of the input is not strict enough to reliably use the SQL parts in queries directly.

Definition at line 31 of file QueryHelper.php.

Member Function Documentation

◆ getDateTimeFormats()

◆ getDateTimeTypes()

◆ parseGroupBy()

static array string [] TYPO3\CMS\Core\Database\Query\QueryHelper::parseGroupBy ( string  $input)
static

Removes the prefix "GROUP BY" from the input string.

This function should be used when you can't guarantee that the string that you want to use as a GROUP BY fragment is not prefixed.

Parameters
string$input‪eg. "GROUP BY title, uid
Returns
‪array|string[] column names to group by

Definition at line 102 of file QueryHelper.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\getSelectQuery(), TYPO3\CMS\Core\Tests\Unit\Database\Query\QueryHelperTest\parseGroupByTest(), and TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider\processForeignTableClause().

◆ parseJoin()

static array TYPO3\CMS\Core\Database\Query\QueryHelper::parseJoin ( string  $input)
static

Split a JOIN SQL fragment into table name, alias and join conditions.

Parameters
string$input‪eg. "JOIN tableName AS a ON a.uid = anotherTable.uid_foreign"
Returns
‪array assoc array consisting of the keys tableName, tableAlias and joinCondition

Definition at line 115 of file QueryHelper.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Database\Query\QueryHelperTest\parseJoinSplitsStatement().

◆ parseOrderBy()

static array array [] TYPO3\CMS\Core\Database\Query\QueryHelper::parseOrderBy ( string  $input)
static

Takes an input, possibly prefixed with ORDER BY, and explodes it into and array of arrays where each item consists of a fieldName and an order direction.

Each of the resulting fieldName/direction pairs can be used passed into QueryBuilder::orderBy() so sort a query result set.

Parameters
string$input‪eg . "ORDER BY title, uid
Returns
‪array|array[] Array of arrays containing fieldName/direction pairs

Definition at line 44 of file QueryHelper.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider\buildForeignTableQueryBuilder(), TYPO3\CMS\Core\Resource\Search\FileSearchQuery\createForSearchDemand(), TYPO3\CMS\Impexp\Export\execListQueryPid(), TYPO3\CMS\Backend\Tree\View\AbstractTreeView\getDataInit(), TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getFileMountRecords(), TYPO3\CMS\Backend\View\BackendLayout\ContentFetcher\getQueryBuilder(), TYPO3\CMS\Backend\RecordList\DatabaseRecordList\getQueryBuilder(), TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\getSelectQuery(), TYPO3\CMS\Core\Domain\Repository\PageRepository\getSubpagesForPages(), TYPO3\CMS\Core\Tests\Unit\Database\Query\QueryHelperTest\parseOrderByTest(), TYPO3\CMS\Backend\Form\Wizard\SuggestWizardDefaultReceiver\prepareOrderByStatement(), TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider\processForeignTableClause(), TYPO3\CMS\Core\Database\RelationHandler\readForeignField(), TYPO3\CMS\Core\Database\RelationHandler\sortList(), and TYPO3\CMS\Core\Database\RelationHandler\writeForeignField().

◆ parseTableList()

static array array [] TYPO3\CMS\Core\Database\Query\QueryHelper::parseTableList ( string  $input)
static

Takes an input, possibly prefixed with FROM, and explodes it into and array of arrays where each item consists of a tableName and an optional alias name.

Each of the resulting pairs can be used with QueryBuilder::from() to select from one or more tables.

Parameters
string$input‪eg . "FROM aTable, anotherTable AS b, aThirdTable c"
Returns
‪array|array[] Array of arrays containing tableName/alias pairs

Definition at line 72 of file QueryHelper.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Tests\Unit\Database\Query\QueryHelperTest\parseTableListTest().

◆ quoteDatabaseIdentifiers()

◆ stripLogicalOperatorPrefix()

static string TYPO3\CMS\Core\Database\Query\QueryHelper::stripLogicalOperatorPrefix ( string  $constraint)
static

Removes the prefixes AND/OR from the input string.

This function should be used when you can't guarantee that the string that you want to use as a WHERE fragment is not prefixed.

Parameters
string$constraint‪The where part fragment with a possible leading AND or OR operator
Returns
‪string The modified where part without leading operator

Definition at line 171 of file QueryHelper.php.

Referenced by TYPO3\CMS\Backend\Form\Wizard\SuggestWizardDefaultReceiver\__construct(), TYPO3\CMS\Backend\Search\LiveSearch\PageRecordProvider\buildConstraintsForTable(), TYPO3\CMS\Backend\Search\LiveSearch\DatabaseRecordProvider\buildConstraintsForTable(), TYPO3\CMS\Linkvalidator\QueryRestrictions\EditableRestriction\buildExpression(), TYPO3\CMS\Core\Domain\Repository\PageRepository\checkValidShortcutOfPage(), TYPO3\CMS\Core\DataHandling\DataHandler\discardMmRelations(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execPHashListQuery(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchAllPages(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchFilteredTree(), TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider\generateItems(), TYPO3\CMS\Linkvalidator\Repository\PagesRepository\getAllSubpagesForPage(), TYPO3\CMS\Backend\Tree\View\AbstractTreeView\getCount(), TYPO3\CMS\Backend\Tree\View\AbstractTreeView\getDataInit(), TYPO3\CMS\Core\Domain\Repository\PageRepository\getDefaultConstraints(), TYPO3\CMS\Core\Database\RelationHandler\getFromDB(), TYPO3\CMS\IndexedSearch\Domain\Repository\AdministrationRepository\getGeneralSearchStatistic(), TYPO3\CMS\Core\Domain\Repository\PageRepository\getPage(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getPageRecords(), TYPO3\CMS\Seo\XmlSitemap\PagesXmlSitemapDataProvider\getPages(), TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager\getRecursiveStoragePids(), TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\getSelectQuery(), TYPO3\CMS\Backend\Controller\Page\MovePageController\getSubpagesForPageId(), TYPO3\CMS\Core\Domain\Repository\PageRepository\getSubpagesForPages(), TYPO3\CMS\Linkvalidator\Repository\PagesRepository\getTranslationForPage(), TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\getTreeList(), TYPO3\CMS\Workspaces\Service\WorkspaceService\getTreeUids(), TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\makeOptionList(), TYPO3\CMS\Backend\RecordList\DatabaseRecordList\makeSearchString(), TYPO3\CMS\Backend\Controller\Page\MovePageController\pageHasSubpages(), TYPO3\CMS\Backend\Form\Wizard\SuggestWizardDefaultReceiver\prepareSelectStatement(), TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider\processForeignTableClause(), TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController\queryMaker(), TYPO3\CMS\Core\Database\RelationHandler\readMM(), TYPO3\CMS\Recycler\Domain\Model\DeletedRecords\resolveTree(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\searchSentence(), TYPO3\CMS\Core\Tests\Unit\Database\Query\QueryHelperTest\stripLogicalOperatorPrefixRemovesConstraintPrefixes(), and TYPO3\CMS\Core\Database\RelationHandler\writeMM().