我在createQueryBuilder中遇到DATE_FORMAT的一些问题
原文链接:https://www.f2er.com/php/135333.html我的代码:
$qb7Days = $repo->createQueryBuilder('R') ->select( 'R.createdAt' ) ->where( "DATE_FORMAT(R.createdAt,'%Y-%m-%d') = :afterDays" ) ->andWhere( 'R.cCurrentReviewState = :state' ) ->andWhere( 'R.reminder = :reminder' ) ->setParameter( 'afterDays',$after7Days ) ->setParameter( 'state',$oReviewStateNotVerified ) // not_verified ->setParameter( 'reminder',0 ) // never sent any reminder ->orderBy( 'R.id','ASC' ) ->getQuery();
但我得到了
[Doctrine\ORM\Query\QueryException] [Syntax Error] line 0,col 7: Error: Expected known function,got 'DATE_FORMAT'
我搜索了一些链接,并找到一些解释,它应该以这种方式工作,但对我来说,它看起来像我做错了.
http://www.uvd.co.uk/blog/labs/using-mysqls-date_format-in-doctrine-2-0/