예제 #1
0
 /**
  * 获取某个广告位的多少条广告订单到数组
  * @param $adid 广告位
  * @param $limit 多少个
  * @param $hash 是否随机获取
  */
 public function outputAdToArray($adid, $limit = 1, $hash = false, $cacheTime = 3600)
 {
     global $Db, $db_prefix;
     $order = $hash ? 'last_click_time desc' : 'rand()';
     $sql = "select order_id,title,url,text,img,code,class from `" . $db_prefix . "adv_order` where start_date<=" . str::getNowTime() . " and stop_date>=" . str::getNowTime() . " and state=" . self::AD_ORDER_STATE_PASSED . " and adv_id={$adid} order by {$order} limit {$limit}";
     $rows = $Db->fetchAlls($sql, $cacheTime);
     if (!empty($rows)) {
         $orderids = array();
         foreach ($rows as $row) {
             $orderids[] = $row['order_id'];
         }
         $orderids = implode(',', $orderids);
         $sql = "update `" . $db_prefix . "adv_order` set show_times=show_times+1 where order_id in({$orderids})";
         $Db->querys($sql);
     }
     return $rows;
 }