具有重复值的 Doctrine 1 select 列

Doctrine 1 select column with duplicate values

我有一个查询将显示具有重复或超过 1 个的列 values.I 可以使用 sql

显示它
select date_created,loan_id,count(1) as cnt
from collections
group by date_created,loan_id
having count(1)>1;

我想把它转换成 Doctrine 1 查询,我试过了

 public function getDuplicateDatePayment() {
    $q = $this->createQuery('c')
               ->select('c.date_created,c.loan_id,c.count(1) as cnt')
               ->groupBy('c.date_created','c.loan_id')
               ->having('c.count(1) > 1');
               return $q->execute();
}     

但它只是 return errors.Any 关于如何将所述工作 sql 正确转换为学说 1 查询的想法?

SQLSTATE[42000]: Syntax error or access violation: 1630 FUNCTION c.count     does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual. Failing Query: "SELECT c.id AS c__id, c.date_created AS c__date_created, c.loan_id AS c__loan_id, c.count(1) AS c__0, c.count(1) AS c__0 FROM collections c GROUP BY c.date_created HAVING c.count(1) > 1"

我希望问题可能出在计数上。尝试以下

public function getDuplicateDatePayment() {
    $q = $this->createQuery('c')
               ->select('c.date_created,c.loan_id,count(c.1) as cnt')
               ->groupBy('c.date_created','c.loan_id')
               ->having('c.count(1) > 1');
               return $q->execute();
}