‪TYPO3CMS  10.4
LikeWildcard.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
26 final class ‪LikeWildcard extends ‪Enumeration
27 {
29 
31  const ‪NONE = 0;
32 
34  const ‪LEFT = 1;
35 
37  const ‪RIGHT = 2;
38 
40  const ‪BOTH = 3;
41 
50  public function ‪getLikeQueryPart($tableName, $fieldName, $likeValue)
51  {
52  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
53  ->getQueryBuilderForTable($tableName);
54 
55  $string = ($this->value & self::LEFT ? '%' : '')
56  . $queryBuilder->escapeLikeWildcards($likeValue)
57  . ($this->value & self::RIGHT ? '%' : '');
58 
59  return $queryBuilder->expr()->like($fieldName, $queryBuilder->quote($string));
60  }
61 }
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard\getLikeQueryPart
‪string getLikeQueryPart($tableName, $fieldName, $likeValue)
Definition: LikeWildcard.php:50
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard
Definition: LikeWildcard.php:27
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard\LEFT
‪const LEFT
Definition: LikeWildcard.php:34
‪TYPO3\CMS\IndexedSearch\Utility
Definition: DoubleMetaPhoneUtility.php:16
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard\BOTH
‪const BOTH
Definition: LikeWildcard.php:40
‪TYPO3\CMS\Core\Type\Enumeration
Definition: Enumeration.php:29
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard\RIGHT
‪const RIGHT
Definition: LikeWildcard.php:37
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard\__default
‪const __default
Definition: LikeWildcard.php:28
‪TYPO3\CMS\IndexedSearch\Utility\LikeWildcard\NONE
‪const NONE
Definition: LikeWildcard.php:31