我想這是一個非常微不足道的問題,但我不知道如何在我的Symfony2項目中安裝Doctrine Extensions - https://github.com/beberlei/DoctrineExtensions。我需要他們,因爲MONTH,YEAR職能。我應該在哪裏放他們的文件夾?我應該把整個DoctrineExtensions
文件夾?並寫在這裏:如何在Symfony2項目中安裝Doctrine Extensions
<?php
$classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', "/path/to/extensions");
$classLoader->register();
在一個單獨的文件?在哪裏放置以及如何調用它?
,然後這一切我需要使用它們:
public function findOneByYearMonthDay($year, $month, $day)
{
$emConfig = $this->getEntityManager()->getConfiguration();
$emConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\Query\Mysql\Year');
$emConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\Query\Mysql\Month');
$emConfig->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\Query\Mysql\Day');
非常感謝你提前和遺憾再次提出這個問題,但我無法找到一個教程(這讓我感覺更更內疚,因爲我猜這是太瑣碎了,甚至沒有教程)
非常感謝! :)這工作! – Faery
Wats「DAY」的功能? – Shaun
[DAY](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_day)是DAYOFMONTH()的同義詞 –