Exemplo n.º 1
0
 /**
  * Returns the static model of the specified AR class.
  * @return AdminAdcode the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Exemplo n.º 2
0
 /**
  * 获取某个广告位的广告代码,优先从缓存中读取,如果是直接从数据库中修改的,需要在后台更新一下缓存
  * @param string $solt
  * @return array 广告代码数组
  */
 public static function fetchAdcodesWithSolt($solt)
 {
     $solt = trim($solt);
     $cacheID = sprintf(param('cache_adcodes_id'), $solt);
     if (app()->getCache()) {
         $cacheData = app()->getCache()->get($cacheID);
         if ($cacheData !== false) {
             return $cacheData;
         }
     }
     $data = array();
     $cmd = app()->getDb()->createCommand()->select('id')->from(TABLE_ADVERT)->where(array('and', 'solt = :adsolt', 'state = :enabled'), array(':adsolt' => $solt, ':enabled' => BETA_YES));
     $adid = $cmd->queryScalar();
     if ($adid !== false) {
         $data = Adcode::fetchAdcodes($adid);
         if (app()->getCache()) {
             app()->getCache()->set($cacheID, $data);
         }
     }
     return $data;
 }