DoctrineJsonFunctions icon indicating copy to clipboard operation
DoctrineJsonFunctions copied to clipboard

How to use JSON_OBJECT with setParameters

Open michilehr opened this issue 1 year ago • 0 comments

Hi,

How can I use JSON_OBJECT with setParameters?

When try to use it like this:

$qb = $em->createQueryBuilder()
    ->select('count(q)')
    ->from(MyClass::class, q)
    ->andWhere('q.myArray = JSON_OBJECT(:key, :value)')
    ->setParameters([
        'key' => "name",
        'value' => "Max"
    ])
    
$ab->getQuery()->getSingleScalarResult();

I get following error:

[Doctrine\ORM\Query\QueryException] [Syntax Error] line 0, col 122: Error: Expected string, got ':utmParameterKey'

Thank you for your help!

Michi

michilehr avatar Sep 07 '23 12:09 michilehr