lundi 10 août 2015

Text environment: "Function "year" does not supported for platform "sqlite""

Incorporating beberlei\DoctrineExtensions in the test environment results in

Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Syntax Error] Function "year" does not supported for platform "sqlite""...

composer show -i includes

beberlei/DoctrineExtensions          v1.0.5

The extensions are installed: they exist at "...vendor\beberlei\DoctrineExtensions".

The month() function does NOT throw an error.

config_test.yml

doctrine:
    dbal:
        default_connection: test
        connections:
            test:
                driver:   pdo_sqlite
                path:     %kernel.cache_dir%/test.sqlite
    orm:
        dql:
            string_functions:
                Soundex: Truckee\VolunteerBundle\DQL\Soundex
                month: DoctrineExtensions\Query\Mysql\Month
            datetime_functions:
                year: DoctrineExtensions\Query\Mysql\Year

function call

public function expiringOppsNotSent()
{
    $nextMonth = date_add(new \DateTime(), new \DateInterval('P1M'));
    $expiryMonth = date_format($nextMonth, 'm');
    $expiryYear = date_format($nextMonth, 'Y');
    $qb = $this->getEntityManager()->createQueryBuilder();
    $qb->select('o')
        ->from('TruckeeVolunteerBundle:Opportunity', 'o')
        ->leftJoin('TruckeeVolunteerBundle:AdminOutbox', 'a', 'WITH', $qb->expr()->eq('a.oppId', 'o'))
        ->andWhere($qb->expr()->eq('month(o.expireDate)', ':month'))
        ->andWhere($qb->expr()->eq('year(o.expireDate)', ':year'))
        ->andWhere('a.id is NULL')
        ->setParameter(':month', $expiryMonth)
        ->setParameter(':year', $expiryYear)
        ;
    $notSent = $qb->getQuery()->getResult();

    return $notSent;
}

Aucun commentaire:

Enregistrer un commentaire