예제 #1
0
 public static function getTopTerms($limit)
 {
     $criteria = new CDbCriteria();
     $thisperiod = round(time() / (86400 * 30));
     $thisperiod--;
     // find the last period one
     $condition = "`search` NOT LIKE '%*%' AND `search` NOT LIKE '%:%' AND `period` = {$thisperiod}";
     $criteria->select = 'search';
     $criteria->condition = $condition;
     $criteria->order = 'frequency DESC';
     $num = $limit * 2;
     $criteria->limit = $num;
     $tops = static::model()->findAll($criteria);
     $returns = array();
     $dealModel = new DealModel();
     foreach ($tops as $t) {
         $exists = $dealModel->isTermExists($t->search);
         if ($exists && strlen($t->search) < 13) {
             $returns[] = $t->search;
         }
     }
     return array_slice($returns, 0, $limit);
 }