api platform postgresql, query builde like text doesn’t work correcty

  api-platform.com, filter, symfony

I’m trying to create a custom filter using symfony and api platform :

$parameterName = $queryNameGenerator->generateParameterName($property);
        $queryBuilder
            ->andWhere(sprintf('o.address LIKE :%s', $parameterName))
            ->orWhere(sprintf('o.email LIKE :%s', $parameterName))
            ->orWhere(sprintf('o.firstName LIKE :%s', $parameterName))
            ->orWhere(sprintf('o.lastName LIKE :%s', $parameterName))
            ->orWhere(sprintf('o.city LIKE :%s', $parameterName))
            ->orWhere(sprintf('o.phone LIKE :%s', $parameterName))
            ->setParameter($parameterName, '%'.$value.'%');

the dd($queryBuilder->getDQL()) give :

enter image description here

The search by address doesn’t work if i pass a text .

It only works when i pass one word

enter image description here

Source: Symfony Questions

LEAVE A COMMENT