‪TYPO3CMS  10.4
QueryBuilder.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Driver\Statement;
21 use Doctrine\DBAL\Platforms\MySqlPlatform;
22 use Doctrine\DBAL\Platforms\OraclePlatform;
23 use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
24 use Doctrine\DBAL\Platforms\SqlitePlatform;
25 use Doctrine\DBAL\Platforms\SQLServerPlatform;
26 use Doctrine\DBAL\Query\Expression\CompositeExpression;
34 
52 {
58  protected ‪$connection;
59 
63  protected ‪$concreteQueryBuilder;
64 
68  protected ‪$restrictionContainer;
69 
74 
85 
94  public function ‪__construct(
97  \Doctrine\DBAL\Query\‪QueryBuilder ‪$concreteQueryBuilder = null,
98  array ‪$additionalRestrictions = null
99  ) {
100  $this->connection = ‪$connection;
101  $this->additionalRestrictions = ‪$additionalRestrictions ?: ‪$GLOBALS['TYPO3_CONF_VARS']['DB']['additionalQueryRestrictions'] ?? [];
102  $this->‪setRestrictions(‪$restrictionContainer ?: GeneralUtility::makeInstance(DefaultRestrictionContainer::class));
103  $this->concreteQueryBuilder = ‪$concreteQueryBuilder ?: GeneralUtility::makeInstance(\Doctrine\DBAL\Query\QueryBuilder::class, ‪$connection);
104  }
105 
109  public function ‪getRestrictions()
110  {
112  }
113 
118  {
119  foreach ($this->additionalRestrictions as $restrictionClass => $options) {
120  if (empty($options['disabled'])) {
122  $restriction = GeneralUtility::makeInstance($restrictionClass);
123  ‪$restrictionContainer->‪add($restriction);
124  }
125  }
126  $this->restrictionContainer = ‪$restrictionContainer;
127  }
128 
134  public function ‪limitRestrictionsToTables(array $tableAliases): void
135  {
136  $this->restrictionContainer = GeneralUtility::makeInstance(LimitToTablesRestrictionContainer::class)->addForTables($this->restrictionContainer, $tableAliases);
137  }
138 
142  public function ‪resetRestrictions()
143  {
144  $this->‪setRestrictions(GeneralUtility::makeInstance(DefaultRestrictionContainer::class));
145  }
146 
156  public function ‪expr(): ‪ExpressionBuilder
157  {
158  return $this->connection->getExpressionBuilder();
159  }
160 
167  public function ‪getType(): int
168  {
169  return $this->concreteQueryBuilder->getType();
170  }
171 
177  public function ‪getConnection(): Connection
178  {
179  return ‪$this->connection;
180  }
181 
188  public function ‪getState(): int
189  {
190  return $this->concreteQueryBuilder->getState();
191  }
192 
199  public function ‪getConcreteQueryBuilder(): \Doctrine\DBAL\Query\QueryBuilder
200  {
202  }
203 
209  public function ‪execute()
210  {
211  if ($this->‪getType() !== \Doctrine\DBAL\Query\QueryBuilder::SELECT) {
212  return $this->concreteQueryBuilder->execute();
213  }
214 
215  // Set additional query restrictions
216  $originalWhereConditions = $this->‪addAdditionalWhereConditions();
217 
218  $result = $this->concreteQueryBuilder->execute();
219 
220  // Restore the original query conditions in case the user keeps
221  // on modifying the state.
222  $this->concreteQueryBuilder->add('where', $originalWhereConditions, false);
223 
224  return $result;
225  }
226 
235  public function ‪getSQL(): string
236  {
237  if ($this->‪getType() !== \Doctrine\DBAL\Query\QueryBuilder::SELECT) {
238  return $this->concreteQueryBuilder->getSQL();
239  }
240 
241  // Set additional query restrictions
242  $originalWhereConditions = $this->‪addAdditionalWhereConditions();
243 
244  $sql = $this->concreteQueryBuilder->getSQL();
245 
246  // Restore the original query conditions in case the user keeps
247  // on modifying the state.
248  $this->concreteQueryBuilder->add('where', $originalWhereConditions, false);
249 
250  return $sql;
251  }
252 
262  public function ‪setParameter($key, $value, int $type = null): QueryBuilder
263  {
264  $this->concreteQueryBuilder->setParameter($key, $value, $type);
265 
266  return $this;
267  }
268 
277  public function ‪setParameters(array $params, array $types = []): QueryBuilder
278  {
279  $this->concreteQueryBuilder->setParameters($params, $types);
280 
281  return $this;
282  }
283 
289  public function ‪getParameters(): array
290  {
291  return $this->concreteQueryBuilder->getParameters();
292  }
293 
301  public function ‪getParameter($key)
302  {
303  return $this->concreteQueryBuilder->getParameter($key);
304  }
305 
311  public function ‪getParameterTypes(): array
312  {
313  return $this->concreteQueryBuilder->getParameterTypes();
314  }
315 
323  public function ‪getParameterType($key)
324  {
325  return $this->concreteQueryBuilder->getParameterType($key);
326  }
327 
335  public function ‪setFirstResult(int $firstResult): QueryBuilder
336  {
337  $this->concreteQueryBuilder->setFirstResult($firstResult);
338 
339  return $this;
340  }
341 
348  public function ‪getFirstResult(): int
349  {
350  return (int)$this->concreteQueryBuilder->getFirstResult();
351  }
352 
360  public function ‪setMaxResults(int $maxResults): QueryBuilder
361  {
362  $this->concreteQueryBuilder->setMaxResults($maxResults);
363 
364  return $this;
365  }
366 
373  public function ‪getMaxResults(): int
374  {
375  return (int)$this->concreteQueryBuilder->getMaxResults();
376  }
377 
390  public function ‪add(string $sqlPartName, $sqlPart, bool $append = false): QueryBuilder
391  {
392  $this->concreteQueryBuilder->add($sqlPartName, $sqlPart, $append);
393 
394  return $this;
395  }
396 
404  public function ‪count(string $item): QueryBuilder
405  {
406  $countExpr = $this->‪getConnection()->getDatabasePlatform()->getCountExpression(
407  $item === '*' ? $item : $this->‪quoteIdentifier($item)
408  );
409  $this->concreteQueryBuilder->‪select($countExpr);
410 
411  return $this;
412  }
413 
421  public function ‪select(string ...$selects): QueryBuilder
422  {
423  $this->concreteQueryBuilder->select(...$this->‪quoteIdentifiersForSelect($selects));
424 
425  return $this;
426  }
427 
434  public function ‪addSelect(string ...$selects): QueryBuilder
435  {
436  $this->concreteQueryBuilder->addSelect(...$this->‪quoteIdentifiersForSelect($selects));
437 
438  return $this;
439  }
440 
450  public function ‪selectLiteral(string ...$selects): QueryBuilder
451  {
452  $this->concreteQueryBuilder->select(...$selects);
453 
454  return $this;
455  }
456 
465  public function ‪addSelectLiteral(string ...$selects): QueryBuilder
466  {
467  $this->concreteQueryBuilder->addSelect(...$selects);
468 
469  return $this;
470  }
471 
483  public function delete(string $delete, string $alias = null): QueryBuilder
484  {
485  $this->concreteQueryBuilder->delete(
486  $this->‪quoteIdentifier($delete),
487  empty($alias) ? $alias : $this->‪quoteIdentifier($alias)
488  );
489 
490  return $this;
491  }
492 
502  public function ‪update(string $update, string $alias = null): QueryBuilder
503  {
504  $this->concreteQueryBuilder->update(
505  $this->‪quoteIdentifier($update),
506  empty($alias) ? $alias : $this->‪quoteIdentifier($alias)
507  );
508 
509  return $this;
510  }
511 
520  public function ‪insert(string $insert): QueryBuilder
521  {
522  $this->concreteQueryBuilder->insert($this->‪quoteIdentifier($insert));
523 
524  return $this;
525  }
526 
536  public function ‪from(string $from, string $alias = null): QueryBuilder
537  {
538  $this->concreteQueryBuilder->from(
539  $this->‪quoteIdentifier($from),
540  empty($alias) ? $alias : $this->‪quoteIdentifier($alias)
541  );
542 
543  return $this;
544  }
545 
556  public function ‪join(string $fromAlias, string $join, string $alias, string $condition = null): QueryBuilder
557  {
558  $this->concreteQueryBuilder->innerJoin(
559  $this->‪quoteIdentifier($fromAlias),
560  $this->‪quoteIdentifier($join),
561  $this->‪quoteIdentifier($alias),
562  $condition
563  );
564 
565  return $this;
566  }
567 
578  public function ‪innerJoin(string $fromAlias, string $join, string $alias, string $condition = null): QueryBuilder
579  {
580  $this->concreteQueryBuilder->innerJoin(
581  $this->‪quoteIdentifier($fromAlias),
582  $this->‪quoteIdentifier($join),
583  $this->‪quoteIdentifier($alias),
584  $condition
585  );
586 
587  return $this;
588  }
589 
600  public function ‪leftJoin(string $fromAlias, string $join, string $alias, string $condition = null): QueryBuilder
601  {
602  $condition = $this->‪expr()->‪andX(
603  $condition,
604  $this->restrictionContainer->buildExpression([$alias ?? $join => $join], $this->expr())
605  );
606  $this->restrictionsAppliedInJoinCondition[] = $alias ?? $join;
607 
608  $this->concreteQueryBuilder->leftJoin(
609  $this->‪quoteIdentifier($fromAlias),
610  $this->‪quoteIdentifier($join),
611  $this->‪quoteIdentifier($alias),
612  $condition
613  );
614 
615  return $this;
616  }
617 
628  public function ‪rightJoin(string $fromAlias, string $join, string $alias, string $condition = null): QueryBuilder
629  {
630  $fromTable = $fromAlias;
631  // find the table belonging to the $fromAlias, if it's an alias at all
632  foreach ($this->‪getQueryPart('from') ?: [] as $from) {
633  if (isset($from['alias']) && $this->‪unquoteSingleIdentifier($from['alias']) === $fromAlias) {
634  $fromTable = $this->‪unquoteSingleIdentifier($from['table']);
635  break;
636  }
637  }
638 
639  $condition = $this->‪expr()->‪andX(
640  $condition,
641  $this->restrictionContainer->buildExpression([$fromAlias => $fromTable], $this->expr())
642  );
643  $this->restrictionsAppliedInJoinCondition[] = $fromAlias;
644 
645  $this->concreteQueryBuilder->rightJoin(
646  $this->‪quoteIdentifier($fromAlias),
647  $this->‪quoteIdentifier($join),
648  $this->‪quoteIdentifier($alias),
649  $condition
650  );
651 
652  return $this;
653  }
654 
665  public function set(string $key, $value, bool $createNamedParameter = true, int $type = \PDO::PARAM_STR): QueryBuilder
666  {
667  $this->concreteQueryBuilder->set(
668  $this->‪quoteIdentifier($key),
669  $createNamedParameter ? $this->‪createNamedParameter($value, $type) : $value
670  );
671 
672  return $this;
673  }
674 
682  public function ‪where(...$predicates): QueryBuilder
683  {
684  $this->concreteQueryBuilder->where(...$predicates);
685 
686  return $this;
687  }
688 
699  public function ‪andWhere(...$where): QueryBuilder
700  {
701  $this->concreteQueryBuilder->andWhere(...$where);
702 
703  return $this;
704  }
705 
716  public function ‪orWhere(...$where): QueryBuilder
717  {
718  $this->concreteQueryBuilder->orWhere(...$where);
719 
720  return $this;
721  }
722 
731  public function ‪groupBy(...$groupBy): QueryBuilder
732  {
733  $this->concreteQueryBuilder->groupBy(...$this->‪quoteIdentifiers($groupBy));
734 
735  return $this;
736  }
737 
745  public function ‪addGroupBy(...$groupBy): QueryBuilder
746  {
747  $this->concreteQueryBuilder->addGroupBy(...$this->‪quoteIdentifiers($groupBy));
748 
749  return $this;
750  }
751 
761  public function ‪setValue(string $column, $value, bool $createNamedParameter = true): QueryBuilder
762  {
763  $this->concreteQueryBuilder->setValue(
764  $this->‪quoteIdentifier($column),
765  $createNamedParameter ? $this->‪createNamedParameter($value) : $value
766  );
767 
768  return $this;
769  }
770 
780  public function ‪values(array $values, bool $createNamedParameters = true): QueryBuilder
781  {
782  if ($createNamedParameters === true) {
783  foreach ($values as &$value) {
784  $value = $this->‪createNamedParameter($value);
785  }
786  }
787 
788  $this->concreteQueryBuilder->values($this->‪quoteColumnValuePairs($values));
789 
790  return $this;
791  }
792 
801  public function ‪having(...$having): QueryBuilder
802  {
803  $this->concreteQueryBuilder->having(...$having);
804  return $this;
805  }
806 
815  public function ‪andHaving(...$having): QueryBuilder
816  {
817  $this->concreteQueryBuilder->andHaving(...$having);
818 
819  return $this;
820  }
821 
830  public function ‪orHaving(...$having): QueryBuilder
831  {
832  $this->concreteQueryBuilder->orHaving(...$having);
833 
834  return $this;
835  }
836 
846  public function ‪orderBy(string $fieldName, string $order = null): QueryBuilder
847  {
848  $this->concreteQueryBuilder->orderBy($this->connection->quoteIdentifier($fieldName), $order);
849 
850  return $this;
851  }
852 
861  public function ‪addOrderBy(string $fieldName, string $order = null): QueryBuilder
862  {
863  $this->concreteQueryBuilder->addOrderBy($this->connection->quoteIdentifier($fieldName), $order);
864 
865  return $this;
866  }
867 
875  public function ‪getQueryPart(string $queryPartName)
876  {
877  return $this->concreteQueryBuilder->getQueryPart($queryPartName);
878  }
879 
885  public function ‪getQueryParts(): array
886  {
887  return $this->concreteQueryBuilder->getQueryParts();
888  }
889 
897  public function ‪resetQueryParts(array $queryPartNames = null): QueryBuilder
898  {
899  $this->concreteQueryBuilder->resetQueryParts($queryPartNames);
900 
901  return $this;
902  }
903 
911  public function ‪resetQueryPart($queryPartName): QueryBuilder
912  {
913  $this->concreteQueryBuilder->resetQueryPart($queryPartName);
914 
915  return $this;
916  }
917 
924  public function ‪__toString(): string
925  {
926  return $this->‪getSQL();
927  }
928 
946  public function ‪createNamedParameter($value, int $type = \PDO::PARAM_STR, string $placeHolder = null): string
947  {
948  return $this->concreteQueryBuilder->createNamedParameter($value, $type, $placeHolder);
949  }
950 
964  public function ‪createPositionalParameter($value, int $type = \PDO::PARAM_STR): string
965  {
966  return $this->concreteQueryBuilder->createPositionalParameter($value, $type);
967  }
968 
976  public function ‪escapeLikeWildcards(string $value): string
977  {
978  return $this->connection->escapeLikeWildcards($value);
979  }
980 
989  public function ‪quote($input, int $type = null)
990  {
991  return $this->‪getConnection()->quote($input, $type);
992  }
993 
1004  public function ‪quoteIdentifier(string $identifier): string
1005  {
1006  return $this->‪getConnection()->‪quoteIdentifier($identifier);
1007  }
1008 
1018  public function ‪quoteIdentifiers(array $input): array
1019  {
1020  return $this->‪getConnection()->‪quoteIdentifiers($input);
1021  }
1022 
1035  public function ‪quoteIdentifiersForSelect(array $input): array
1036  {
1037  foreach ($input as &$select) {
1038  [$fieldName, $alias, $suffix] = array_pad(
1040  ' AS ',
1041  str_ireplace(' as ', ' AS ', $select),
1042  true,
1043  3
1044  ),
1045  3,
1046  null
1047  );
1048  if (!empty($suffix)) {
1049  throw new \InvalidArgumentException(
1050  'QueryBuilder::quoteIdentifiersForSelect() could not parse the select ' . $select . '.',
1051  1461170686
1052  );
1053  }
1054 
1055  // The SQL * operator must not be quoted. As it can only occur either by itself
1056  // or preceded by a tablename (tablename.*) check if the last character of a select
1057  // expression is the * and quote only prepended table name. In all other cases the
1058  // full expression is being quoted.
1059  if (substr($fieldName, -2) === '.*') {
1060  $select = $this->‪quoteIdentifier(substr($fieldName, 0, -2)) . '.*';
1061  } elseif ($fieldName !== '*') {
1062  $select = $this->‪quoteIdentifier($fieldName);
1063  }
1064 
1065  // Quote the alias for the current fieldName, if given
1066  if (!empty($alias)) {
1067  $select .= ' AS ' . $this->‪quoteIdentifier($alias);
1068  }
1069  }
1070  return $input;
1071  }
1072 
1083  public function ‪quoteColumnValuePairs(array $input): array
1084  {
1085  return $this->‪getConnection()->‪quoteColumnValuePairs($input);
1086  }
1087 
1094  public function ‪castFieldToTextType(string $fieldName): string
1095  {
1096  $databasePlatform = $this->connection->getDatabasePlatform();
1097  // https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert
1098  if ($databasePlatform instanceof MySqlPlatform) {
1099  return sprintf('CONVERT(%s, CHAR)', $this->connection->quoteIdentifier($fieldName));
1100  }
1101  // https://www.postgresql.org/docs/current/sql-createcast.html
1102  if ($databasePlatform instanceof PostgreSqlPlatform) {
1103  return sprintf('%s::text', $this->connection->quoteIdentifier($fieldName));
1104  }
1105  // https://www.sqlite.org/lang_expr.html#castexpr
1106  if ($databasePlatform instanceof SqlitePlatform) {
1107  return sprintf('CAST(%s as TEXT)', $this->connection->quoteIdentifier($fieldName));
1108  }
1109  // https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver15#implicit-conversions
1110  if ($databasePlatform instanceof SQLServerPlatform) {
1111  return sprintf('CAST(%s as VARCHAR)', $this->connection->quoteIdentifier($fieldName));
1112  }
1113  // https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj33562.html
1114  if ($databasePlatform instanceof OraclePlatform) {
1115  return sprintf('CAST(%s as VARCHAR)', $this->connection->quoteIdentifier($fieldName));
1116  }
1117 
1118  throw new \RuntimeException(
1119  sprintf(
1120  '%s is not implemented for the used database platform "%s", yet!',
1121  __METHOD__,
1122  get_class($this->connection->getDatabasePlatform())
1123  ),
1124  1584637096
1125  );
1126  }
1127 
1135  protected function ‪unquoteSingleIdentifier(string $identifier): string
1136  {
1137  $identifier = trim($identifier);
1138  $platform = $this->‪getConnection()->getDatabasePlatform();
1139  if ($platform instanceof SQLServerPlatform) {
1140  // mssql quotes identifiers with [ and ], not a single character
1141  $identifier = ltrim($identifier, '[');
1142  $identifier = rtrim($identifier, ']');
1143  } else {
1144  $quoteChar = $platform->getIdentifierQuoteCharacter();
1145  $identifier = trim($identifier, $quoteChar);
1146  $identifier = str_replace($quoteChar . $quoteChar, $quoteChar, $identifier);
1147  }
1148  return $identifier;
1149  }
1150 
1159  protected function ‪getQueriedTables(): array
1160  {
1161  $queriedTables = [];
1162 
1163  // Loop through all FROM tables
1164  foreach ($this->‪getQueryPart('from') as $from) {
1165  $tableName = $this->‪unquoteSingleIdentifier($from['table']);
1166  $tableAlias = isset($from['alias']) ? $this->‪unquoteSingleIdentifier($from['alias']) : $tableName;
1167  if (!in_array($tableAlias, $this->restrictionsAppliedInJoinCondition, true)) {
1168  $queriedTables[$tableAlias] = $tableName;
1169  }
1170  }
1171 
1172  // Loop through all JOIN tables
1173  foreach ($this->‪getQueryPart('join') as $fromTable => $joins) {
1174  foreach ($joins as $join) {
1175  $tableName = $this->‪unquoteSingleIdentifier($join['joinTable']);
1176  $tableAlias = isset($join['joinAlias']) ? $this->‪unquoteSingleIdentifier($join['joinAlias']) : $tableName;
1177  if (!in_array($tableAlias, $this->restrictionsAppliedInJoinCondition, true)) {
1178  $queriedTables[$tableAlias] = $tableName;
1179  }
1180  }
1181  }
1182 
1183  return $queriedTables;
1184  }
1185 
1193  protected function ‪addAdditionalWhereConditions()
1194  {
1195  $originalWhereConditions = $this->concreteQueryBuilder->getQueryPart('where');
1196  $expression = $this->restrictionContainer->buildExpression($this->‪getQueriedTables(), $this->‪expr());
1197  // This check would be obsolete, as the composite expression would not add empty expressions anyway
1198  // But we keep it here to only clone the previous state, in case we really will change it.
1199  // Once we remove this state preserving functionality, we can remove the count check here
1200  // and just add the expression to the query builder.
1201  if ($expression->count() > 0) {
1202  if ($originalWhereConditions instanceof CompositeExpression) {
1203  // Save the original query conditions so we can restore
1204  // them after the query has been built.
1205  $originalWhereConditions = clone $originalWhereConditions;
1206  }
1207  $this->concreteQueryBuilder->andWhere($expression);
1208  }
1209 
1210  return $originalWhereConditions;
1211  }
1217  public function ‪__clone()
1218  {
1219  $this->concreteQueryBuilder = clone ‪$this->concreteQueryBuilder;
1220  $this->restrictionContainer = clone ‪$this->restrictionContainer;
1221  }
1222 }
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getQueryPart
‪mixed getQueryPart(string $queryPartName)
Definition: QueryBuilder.php:870
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\quoteIdentifier
‪string quoteIdentifier(string $identifier)
Definition: QueryBuilder.php:999
‪TYPO3\CMS\Core\Database\Connection\select
‪Statement Doctrine DBAL ForwardCompatibility Result Doctrine DBAL Driver ResultStatement select(array $columns, string $tableName, array $identifiers=[], array $groupBy=[], array $orderBy=[], int $limit=0, int $offset=0)
Definition: Connection.php:257
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\set
‪QueryBuilder set(string $key, $value, bool $createNamedParameter=true, int $type=\PDO::PARAM_STR)
Definition: QueryBuilder.php:660
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\__toString
‪string __toString()
Definition: QueryBuilder.php:919
‪TYPO3\CMS\Core\Database\Query\Restriction\LimitToTablesRestrictionContainer
Definition: LimitToTablesRestrictionContainer.php:28
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\resetRestrictions
‪resetRestrictions()
Definition: QueryBuilder.php:137
‪TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder
Definition: ExpressionBuilder.php:35
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\groupBy
‪QueryBuilder groupBy(... $groupBy)
Definition: QueryBuilder.php:726
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\innerJoin
‪QueryBuilder innerJoin(string $fromAlias, string $join, string $alias, string $condition=null)
Definition: QueryBuilder.php:573
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\andHaving
‪QueryBuilder andHaving(... $having)
Definition: QueryBuilder.php:810
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getParameters
‪array getParameters()
Definition: QueryBuilder.php:284
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\select
‪QueryBuilder select(string ... $selects)
Definition: QueryBuilder.php:416
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\rightJoin
‪QueryBuilder rightJoin(string $fromAlias, string $join, string $alias, string $condition=null)
Definition: QueryBuilder.php:623
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getType
‪int getType()
Definition: QueryBuilder.php:162
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\values
‪QueryBuilder values(array $values, bool $createNamedParameters=true)
Definition: QueryBuilder.php:775
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\resetQueryPart
‪QueryBuilder resetQueryPart($queryPartName)
Definition: QueryBuilder.php:906
‪TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface
Definition: QueryRestrictionInterface.php:27
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\$restrictionContainer
‪QueryRestrictionContainerInterface $restrictionContainer
Definition: QueryBuilder.php:65
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getQueriedTables
‪string[] getQueriedTables()
Definition: QueryBuilder.php:1154
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\createNamedParameter
‪string createNamedParameter($value, int $type=\PDO::PARAM_STR, string $placeHolder=null)
Definition: QueryBuilder.php:941
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\__clone
‪__clone()
Definition: QueryBuilder.php:1212
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\escapeLikeWildcards
‪string escapeLikeWildcards(string $value)
Definition: QueryBuilder.php:971
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getParameter
‪mixed getParameter($key)
Definition: QueryBuilder.php:296
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\setValue
‪QueryBuilder setValue(string $column, $value, bool $createNamedParameter=true)
Definition: QueryBuilder.php:756
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\join
‪QueryBuilder join(string $fromAlias, string $join, string $alias, string $condition=null)
Definition: QueryBuilder.php:551
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\orderBy
‪QueryBuilder orderBy(string $fieldName, string $order=null)
Definition: QueryBuilder.php:841
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\quoteIdentifiers
‪array quoteIdentifiers(array $input)
Definition: QueryBuilder.php:1013
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\setParameter
‪QueryBuilder setParameter($key, $value, int $type=null)
Definition: QueryBuilder.php:257
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\quoteColumnValuePairs
‪array quoteColumnValuePairs(array $input)
Definition: QueryBuilder.php:1078
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getMaxResults
‪int getMaxResults()
Definition: QueryBuilder.php:368
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getRestrictions
‪QueryRestrictionContainerInterface getRestrictions()
Definition: QueryBuilder.php:104
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\addSelect
‪QueryBuilder addSelect(string ... $selects)
Definition: QueryBuilder.php:429
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getConnection
‪Connection getConnection()
Definition: QueryBuilder.php:172
‪TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionContainerInterface
Definition: QueryRestrictionContainerInterface.php:25
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\update
‪QueryBuilder update(string $update, string $alias=null)
Definition: QueryBuilder.php:497
‪TYPO3\CMS\Core\Database\Connection\quoteIdentifier
‪string quoteIdentifier($identifier)
Definition: Connection.php:133
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\$connection
‪Connection $connection
Definition: QueryBuilder.php:57
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\unquoteSingleIdentifier
‪string unquoteSingleIdentifier(string $identifier)
Definition: QueryBuilder.php:1130
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\quoteIdentifiersForSelect
‪array quoteIdentifiersForSelect(array $input)
Definition: QueryBuilder.php:1030
‪TYPO3\CMS\Core\Database\Query\QueryBuilder
Definition: QueryBuilder.php:52
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\from
‪QueryBuilder from(string $from, string $alias=null)
Definition: QueryBuilder.php:531
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getSQL
‪string getSQL()
Definition: QueryBuilder.php:230
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getConcreteQueryBuilder
‪Doctrine DBAL Query QueryBuilder getConcreteQueryBuilder()
Definition: QueryBuilder.php:194
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\__construct
‪__construct(Connection $connection, QueryRestrictionContainerInterface $restrictionContainer=null, \Doctrine\DBAL\Query\QueryBuilder $concreteQueryBuilder=null, array $additionalRestrictions=null)
Definition: QueryBuilder.php:89
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getQueryParts
‪array getQueryParts()
Definition: QueryBuilder.php:880
‪TYPO3\CMS\Core\Database\Connection\quoteColumnValuePairs
‪array quoteColumnValuePairs(array $input)
Definition: Connection.php:166
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\andWhere
‪QueryBuilder andWhere(... $where)
Definition: QueryBuilder.php:694
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getState
‪int getState()
Definition: QueryBuilder.php:183
‪TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\andX
‪CompositeExpression andX(... $expressions)
Definition: ExpressionBuilder.php:70
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\delete
‪QueryBuilder delete(string $delete, string $alias=null)
Definition: QueryBuilder.php:478
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\execute
‪Statement Doctrine DBAL ForwardCompatibility Result Doctrine DBAL Driver ResultStatement int execute()
Definition: QueryBuilder.php:204
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\addGroupBy
‪QueryBuilder addGroupBy(... $groupBy)
Definition: QueryBuilder.php:740
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\selectLiteral
‪QueryBuilder selectLiteral(string ... $selects)
Definition: QueryBuilder.php:445
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\addAdditionalWhereConditions
‪Doctrine DBAL Query Expression CompositeExpression mixed addAdditionalWhereConditions()
Definition: QueryBuilder.php:1188
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\insert
‪QueryBuilder insert(string $insert)
Definition: QueryBuilder.php:515
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\$concreteQueryBuilder
‪Doctrine DBAL Query QueryBuilder $concreteQueryBuilder
Definition: QueryBuilder.php:61
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\createPositionalParameter
‪string createPositionalParameter($value, int $type=\PDO::PARAM_STR)
Definition: QueryBuilder.php:959
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getFirstResult
‪int getFirstResult()
Definition: QueryBuilder.php:343
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\setMaxResults
‪QueryBuilder setMaxResults(int $maxResults)
Definition: QueryBuilder.php:355
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\resetQueryParts
‪QueryBuilder resetQueryParts(array $queryPartNames=null)
Definition: QueryBuilder.php:892
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\$restrictionsAppliedInJoinCondition
‪string[] $restrictionsAppliedInJoinCondition
Definition: QueryBuilder.php:79
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:36
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\add
‪QueryBuilder add(string $sqlPartName, $sqlPart, bool $append=false)
Definition: QueryBuilder.php:385
‪TYPO3\CMS\Core\Database\Connection\quoteIdentifiers
‪array quoteIdentifiers(array $input)
Definition: Connection.php:151
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\limitRestrictionsToTables
‪limitRestrictionsToTables(array $tableAliases)
Definition: QueryBuilder.php:129
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\setFirstResult
‪QueryBuilder setFirstResult(int $firstResult)
Definition: QueryBuilder.php:330
‪TYPO3\CMS\Core\Database\Query
Definition: BulkInsertQuery.php:18
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getParameterType
‪mixed getParameterType($key)
Definition: QueryBuilder.php:318
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\orWhere
‪QueryBuilder orWhere(... $where)
Definition: QueryBuilder.php:711
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\quote
‪mixed quote($input, int $type=null)
Definition: QueryBuilder.php:984
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\addOrderBy
‪QueryBuilder addOrderBy(string $fieldName, string $order=null)
Definition: QueryBuilder.php:856
‪TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionContainerInterface\add
‪QueryRestrictionContainerInterface add(QueryRestrictionInterface $restriction)
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\$additionalRestrictions
‪array $additionalRestrictions
Definition: QueryBuilder.php:69
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\count
‪QueryBuilder count(string $item)
Definition: QueryBuilder.php:399
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\setRestrictions
‪setRestrictions(QueryRestrictionContainerInterface $restrictionContainer)
Definition: QueryBuilder.php:112
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\having
‪QueryBuilder having(... $having)
Definition: QueryBuilder.php:796
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\addSelectLiteral
‪QueryBuilder addSelectLiteral(string ... $selects)
Definition: QueryBuilder.php:460
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\where
‪QueryBuilder where(... $predicates)
Definition: QueryBuilder.php:677
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\expr
‪ExpressionBuilder expr()
Definition: QueryBuilder.php:151
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\setParameters
‪QueryBuilder setParameters(array $params, array $types=[])
Definition: QueryBuilder.php:272
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\orHaving
‪QueryBuilder orHaving(... $having)
Definition: QueryBuilder.php:825
‪TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer
Definition: DefaultRestrictionContainer.php:24
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\leftJoin
‪QueryBuilder leftJoin(string $fromAlias, string $join, string $alias, string $condition=null)
Definition: QueryBuilder.php:595
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\castFieldToTextType
‪string castFieldToTextType(string $fieldName)
Definition: QueryBuilder.php:1089
‪TYPO3\CMS\Core\Database\Query\QueryBuilder\getParameterTypes
‪array getParameterTypes()
Definition: QueryBuilder.php:306