I get the error Attempted to load class "Month" from namespace "DoctrineExtensions\Query\Mysql". Did you forget a "use" statement for another namespace
when i'm trying to create a query that fetch data by year and month
Inside my repository
public function getCongePris($mois,$annee,$matricule)
{
$emConfig = $this->_em->getConfiguration();
$emConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\Query\Mysql\Year');
$emConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\Query\Mysql\Month');
$qb = $this->createQueryBuilder('co')->leftJoin('co.personnel','p');
$qb->select('co')
->where('p.matricule= :matricule')->andWhere('co.statutDemande=:statut ')
->andWhere('MONTH( co.debutConge)=:mois')->andWhere('YEAR(co.debutConge)=:annee');
$qb->setParameter('annee',$annee)->setParameter('mois',$mois)->setParameter('matricule',$matricule)->setParameter('statut','ACCEPTE');
$conges = $qb->getQuery()->getResult();
return $conges;
}
Inside my config.yml
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
string_functions:
MONTH: DoctrineExtensions\Query\Mysql\Month
YEAR: DoctrineExtensions\Query\Mysql\Year