TYPO3: Case sensitive search with BINARY in Doctrine where clause

339 views Asked by At

I'm currently migrating an old TYPO3 application from $GLOBALS['TYPO3_DB'] to Doctrine.

In the old application there was a case sensitive search with the BINARY operator:

$whereClause = 'BINARY myfieldname LIKE "%' . $query . '%"';

I tried to migrate it like this:

$queryBuilder->expr()->like('BINARY myfieldname', $queryBuilder->createNamedParameter('%' . $queryBuilder->escapeLikeWildcards($query) . '%'))

Another attempt was like this:

$queryBuilder->expr()->like('BINARY `myfieldname`', $queryBuilder->createNamedParameter('%' . $queryBuilder->escapeLikeWildcards($query) . '%'))

This always ends up with an error message: Unknown column 'BINARY `label`' in 'where clause'

Unfortunately there is no way to change anything at the MySQL server settings.

I've found this question but it didn't help me.

Any other ideas?

1

There are 1 answers

0
Peter Kraume On

This solution worked for me (thx to the hint of Thomas):

$whereClause = $queryBuilder->expr()->like(
  'label',
  $queryBuilder->createNamedParameter('%' . $queryBuilder->escapeLikeWildcards($query) . '%')
);
$whereClause = 'BINARY ' . $whereClause;
$queryBuilder->add('where', $whereClause);