How can I use DATE() in Doctrine 2 DQL?

后端 未结 3 1047
既然无缘
既然无缘 2020-12-03 18:43

IN Symfony, when i used the following query with DATE function in the mysql i get a error

    SELECT employer.companyName AS employerName, jobs.jobId, jobs.         


        
3条回答
  •  醉话见心
    2020-12-03 19:29

    In addition to the accepted answer there are a tonne of pre-built custom functions available at https://github.com/beberlei/DoctrineExtensions .

    These can be then registered in your config like

    doctrine:
        orm:
            dql:
                string_functions:
                    DATE: DoctrineExtensions\Query\Mysql\Date
    

    and can then be used in your DQL (as in your query) like

    DATE(jobs.endDate) AS endDate
    

提交回复
热议问题