Update entity with query : Expected Literal, got ‘AND’"

I wrote doctrine query builder for updating entity where field endDate is null.

public function update(int $clientId, DateTime $endDate): void
    $qb = $this->createQueryBuilder('s');

    $qb ->update(User::class, 's')
        ->set('s.endDate', $endDate->format("Y-m-d"))
        ->where('s.clientId =:clientId')
            $qb->expr()->neq('s.endDate', null),
            $qb->expr()->gt('s.endDate', $endDate->format("Y-m-d"))
        ->setParameter('clientId', $clientId)

I don’t know where and why this error is coming from:

line 0, col 113: Error: Expected Literal, got ‘AND’"

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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