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