【发布时间】:2013-09-30 00:40:57
【问题描述】:
我使用 codeigniter 和学说,这是我的 bd:
id fecha_publicacion
1 2013-03-23 14:52:06
2 2013-03-23 18:02:06
3 2013-03-23 00:00:00
.. ...
我想做的是从某个日期或某个日期范围内搜索那些出版物
问题是,如果我想选择所有日期为 2013-03-23 的字段,我的查询只返回第三个字段(时间为 00:00:00)
我该怎么做才能得到我想要的?我尝试了很多东西,但都没有成功
public function postsByDates($tipo,$fecha1,$fecha2=''){
if($fecha2 == ''){
$fecha2 = $fecha1;
}
$this->qb = $this->em->createQueryBuilder();
$this->qb->select('p')
->from('models\Post', 'p')
->where(
$this->qb->expr()->eq('p.tipo', '?1'),
$this->qb->expr()->between('p.fecha_publicacion', '?2', '?3')
)
->setParameter(1, $tipo)
->setParameter(2, "$fecha1%")
->setParameter(3, "$fecha2%");
$query = $this->qb->getQuery();
$obj = $query->getResult();
return $obj;
}
【问题讨论】:
标签: doctrine-orm doctrine dql doctrine-query