Doctrine2 loading DoctrineExtensions



我想在我的doctrine2查询构建器中使用day()和年度()函数。但是我不断地遇到错误:

Fatal error: Uncaught DoctrineORMQueryQueryException: SELECT DAY(h.date) AS day FROM EntitiesHit h GROUP BY day in

PHP代码:

$totalHits = $this->registry->entityManager->getRepository('EntitiesHit')
->createQueryBuilder('h')
->select('DAY(h.date) AS day')
->groupBy('day')
->getQuery()->getResult();`

通过作曲家或通过自动加载器加载学说延迟,无法修复它:

$classLoader = new DoctrineCommonClassLoader('DoctrineExtensions', __DIR__.'/../vendor/beberlei/DoctrineExtensions');
$classLoader->register();

我是错误地加载了教义延迟还是有其他东西?

修复。添加:

$entityManagerConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensionsQuerySqliteYear');
$entityManagerConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensionsQuerySqliteMonth');
$entityManagerConfig->addCustomDatetimeFunction('DAY', 'DoctrineExtensionsQuerySqliteDay');

解决了问题

相关内容

  • 没有找到相关文章

最新更新