【问题标题】:Set boolean to 1 with doctrine使用学说将布尔值设置为 1
【发布时间】:2014-10-19 13:25:53
【问题描述】:

我尝试使用教义提出一个非常简单的请求,但遇到了一些麻烦:

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

请求正在执行且没有错误,但更新没有。 此请求必须在“有效”字段中输入 1。 表中的某些项目与 3 where 子句匹配。

怎么了?

感谢您的帮助

【问题讨论】:

标签: php mysql symfony doctrine-orm


【解决方案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.

【讨论】:

    猜你喜欢
    • 2017-08-31
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-12
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    相关资源
    最近更新 更多