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

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

$parameterName = $queryNameGenerator->generateParameterName($property);
            ->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

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *