我使用 Symfony2 进行了以下查询,我想将字段(2013-08-31) 转换i.fechaInicio
为当前周数,以便我可以从当前周获取结果...date
Y-m-d
$now = new \DateTime();
$semana = $now->format('W'); // Week Number
$query = $this->getEntityManager()
->createQuery("
SELECT i
FROM PgeIncidenciasBundle:Incidencia i
WHERE i.fechaInicio = :semana // This is wrong because compares
// Y-m-d with W so no results found...
")
->setParameters(array(
'semana' => $semana
))
;
try {
return $query->getResult();
}
catch (\Doctrine\ORM\NoResultException $e)
{
return null;
}