如何在 cakephp 中使用与 mysql 不同的日期仅获取年份



检查下面的代码:

$this->set('hi', $this->posts->find('all',
array('fields'=>array('DISTINCT year(posts.Post_date)'))));

我没有得到正确的结果...任何人都可以帮我...

我的查询是(从帖子中选择不同的年份(post_date);

谢谢

替换下面

`DISTINCT year(posts.Post_date)`

与以下:-

YEAR(DISTINCT posts.Post_date) as year

最新更新