1

I'm using TYPO3 version 8.7.x and I'm currently struggeling with using an "rlike" expression in combination with the QueryBuilder.

Here is a snippet:

    $this->getQueryBuilder()
        ->select('uid')
        ->from(self::DEFAULT_TABLE)
        ->where(
            $this->getQueryBuilder()->expr()->  // here I expected the rlike expression
        )

Question: Since there is no build in method for rlike, how do I build an where-clause with regex expressions?

I already figured out that comparison($leftExpression, string $operator, $rightExpression) can be used to force an rlike-string but if used you have to exploit the missing $operator check to include an 'rlike' statement.
By default $operator should be used as an ExpressionBuilder constant.
@param string $operator One of the ExpressionBuilder::* constants.

Sidenote: The comparison-function might be used as an expolit if you are working with generic statements. So I would like to avoid this way

The QueryBuilder is using an instance of \Doctrine\DBAL\Query\Expression\ExpressionBuilder

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Spears
  • 2,102
  • 1
  • 17
  • 27
  • You're not showing object type of `$this`, but I'm thinking it might be a child of `EntityRepository` ? You need to run `->getQueryBuilder` from the EntityManager to get an instance of `\Doctrine\ORM\QueryBuilder` instead of DBAL (those 2 QueryBuilders _are not_ the same). Following that, check out [this answer](https://stackoverflow.com/a/29034983/1155833) – rkeet Jun 27 '19 at 08:23
  • @rkeet I aleady pointed out that I'm working with TYPO3 nto Symfony. It doesn't matter what `$this` refers to since im getting an instance of the TYPO3 QueryBuilder `TYPO3\CMS\Core\Database\Query\QueryBuilder`. Thios QueryBuilder is like a proxy for the real query builder (in thic context called "concreteQueryBuilder"). – Spears Jun 27 '19 at 10:54
  • Haven't mentioned SF ;-) Though I use both SF & ZF. Anyway, have you got [this repo](https://github.com/beberlei/DoctrineExtensions) in your project? Provides a whole lot of additional functions, such as MySQL REGEXP. Have a look at the readme file. – rkeet Jun 27 '19 at 11:44

0 Answers0