我尝试使用
进行数据库查询$position = $repository->findBy(
array('id' => $profileId,'datum' => '10.07.2011'),
array('timestamp', 'DESC')
);
数据库看起来像
id haveInCircles inOtherCircles datum timestamp
1 24 14 11.07.2011 1310403840
1 20 10 10.07.2011 1310317440
1 10 5 09.07.2011 1310317440
1 25 17 12.07.2011 1310468838
我得到的结果总是最后一天的数据入库。在本例中为“12.07.2011”。
最佳答案
对日期使用 varchar 可能是最糟糕的方法。将数据字段更改为日期或日期时间,相应地更改您的模型,使 Doctrine 字段为日期,然后执行以下操作:
$position = $repository->findBy(
array('id' => $profileId,'datum' => new Datetime('2011-07-10')),
array('timestamp' => 'DESC')
);
http://www.php.net/manual/en/datetime.construct.php
我建议复习的模式实践简介: http://brixican.blogspot.ca/2011/04/5-mysql-best-practices-when-designing.html
关于doctrine - Symfony2 Doctrine ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6663988/