Patricia
Patricia

Reputation: 13

YEAR() and MONTH() in Doctrine2 with Symfony 2.4

I've just installed StofDoctrineExtensionsBundle to use SQL functions MONTH() and YEAR() but I keep getting this error:

Attempted to load class "Month" from namespace "DoctrineExtensions\Query\Mysql" in /var/www/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 3389. Do you need to "use" it from another namespace?

In my controller I have this:

$dql = "SELECT x FROM PFCFisiogestBundle:FacturaEmitida x WHERE MONTH(x.fecha) BETWEEN '".$mes_inicio."' AND '".$mes_fin."' 
                AND YEAR(x.fecha) = '".$ano."' ORDER BY x.numero DESC";
$queryDefault = $em->createQuery($dql);

And in config.yml

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
        dql:
            string_functions:
                MONTH: DoctrineExtensions\Query\Mysql\Month
                YEAR: DoctrineExtensions\Query\Mysql\Year

What am I missing? :-(

Upvotes: 0

Views: 1834

Answers (1)

drAlberT
drAlberT

Reputation: 23228

That bundle is a sf2 wrapper for behavioural Doctrine extensions, which is a different case than yours

Try this orocrm/doctrine-extensions .. it supports MySQL and Postgres too ... should support other DBMS in future

Upvotes: 2

Related Questions