【问题标题】:Doctrine query, error教义查询,错误
【发布时间】:2015-11-30 10:07:11
【问题描述】:

我有疑问:

use Symfony\Component\HttpFoundation\JsonResponse;

$em = $this->getDoctrine()->getManager();
$query = $em->createQuery(
    'SELECT 
       Bank_ID, 
       Status, 
       COUNT(Bank_ID) 
    FROM 
       OmnisoftIntegBundle:IntClientBank 
    WHERE 
       status = 30 or status = 50 or status = 35 or status = 37 
    GROUP BY Bank_ID, Status;'
);

$result = $query->getResult();

return new JsonResponse(array('data' => $result, 'success' => true))

而 symfony 显示错误:

[2/2] QueryException:[语法错误] 第 0 行,第 84 列:错误:预期 字符串结尾,得到 'status' + [1/2] QueryException: SELECT Bank_ID, 来自 OmnisoftIntegBundle:IntClientBank 的状态,COUNT(Bank_ID) WHERE 状态 = 30 或状态 = 50 或状态 = 35 或状态 = 37 分组 Bank_ID,状态;

【问题讨论】:

  • 你知道 IN 谓词可以很容易地为你做 or -> or -> or -> ... -> or 逻辑吗?

标签: sql symfony doctrine


【解决方案1】:

尝试删除';'在您的查询结束时。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 2012-01-06
    相关资源
    最近更新 更多