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

后端 未结 3 1042
既然无缘
既然无缘 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:28

    Or if you don't want add a new dependency, you can use code like this:

    $dateTime = new \DateTime();
    $qb
       ->andWhere('jobs.endDate BETWEEN :dateMin AND :dateMax')
       ->setParameters(
           [
                'dateMin' => $dateTime->format('Y-m-d 00:00:00'),
                'dateMax' => $dateTime->format('Y-m-d 23:59:59'),
           ]
        );
    

提交回复
热议问题