此代码返回预定帖子的列表(名称、日期时间)。
$criteria = new CDbCriteria;
$criteria->select='name, datetime';
$criteria->condition='datetime>:datetime';
$criteria->params=array(':datetime'=>date('Y-m-d H:i:s'));
$criteria->order='DATE_FORMAT(datetime, "%d/%m/%Y") ASC';
$models = Posts::model()->findAll($criteria);
我想对具有相同日期 d/m/Y 的帖子进行 GROUP,然后只代表每个帖子的 H/i/s,这可能吗?
像:
Array
(
[2000/10/10] => Array
(
[1] => Array
(
[name] = Post 1
[time] = 12:10
)
[2] => Array
(
[name] = Post 2
[time] = 16:20
)
[3] => Array
(
[name] = Post 3
[time] = 20:30
)
)
[2000/10/11] => Array
(
[6] => Array
(
[name] = Post 6
[time] = 10:00
)
)
)