public function getChargeRank3() { $startime='2014-04-10 00:00:00'; $endtime='2014-04-30 23:59:59'; $sql="select top 3 user_id, sum (point) as total from table where state=5 and cp_id>=11 and cp_id<=19 and pay_time >='$startime' and pay_time<='$endtime' group by user_id order by total desc"; $result= Yii::app()->controller>createCommand($sql)->queryAll(); $cache = yii::app()->cache->get($key); if($cache!=false) { foreach ($result as $key=>$val) { //这里为内部赠送礼物代码,不便透漏 } } YII::app()->cache->set($key, $result, strtotime($endtime));//把前三名写入缓存 }
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。