-1

I get some troubles with a very simple request that I try to make working with doctrine:

    return $this->createQueryBuilder('l')
                ->set('l.valide', true)
                ->andWhere('l.artiste=:artiste')
                ->andWhere('l.client=:client')
                ->andWhere('l.annonce=:annonce')
                ->setParameters(
                    array(
                        ':artiste' => $artiste,
                        ':client'  => $client,
                        ':annonce' => $annonce
                    ))
                ->getQuery()
                ->getResult();

The request is executing without errors, but the update is not. This request has to put 1 in the field 'valide'. Some items in the table is matching with the 3 where clause.

What is wrong ?

Thanks for help

Macbernie
  • 1,303
  • 6
  • 24
  • 48

1 Answers1

1

Your query builder usage is absolutely wrong. I believe you run this code within a repository? Then your code should look like this:

$this->createQueryBuilder('l')
    ->update() // Forgotten update() method
    ->set('l.valide', true)
    ->andWhere('l.artiste=:artiste')
    ->andWhere('l.client=:client')
    ->andWhere('l.annonce=:annonce')
    ->setParameters(
    array(
        ':artiste' => $artiste,
        ':client'  => $client,
        ':annonce' => $annonce
    ))
    ->getQuery()
    ->execute(); // Execute, "not getResult". It's not a SELECT query.
ozahorulia
  • 9,798
  • 8
  • 48
  • 72