2014-10-19 44 views
-1

我得到一个非常简单的请求一些麻烦,我尽量让教义工作:组布尔1教义

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(); 

请求是没有错误执行,但更新不是。 这个请求必须在字段'valide'中加1。 表中的一些项目与3 where子句匹配。

出了什么问题?

感谢您的帮助

+0

http://stackoverflow.com/questions/4337751/doctrine-2-update-query-with-query-builder – 2014-10-19 13:52:33

回答

1

您的查询生成器的用法是绝对错误的。我相信你在一个存储库中运行这个代码?那么你的代码应该是这样的:

$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. 
+0

真棒,谢谢你岂不的可能的复制 – Macbernie 2014-10-19 14:33:39