예제 #1
0
 public static function saveInstance(array $attr = [])
 {
     // new ad
     if (empty($attr['id'])) {
         $copy = $attr['copy'];
         $url = $attr['url'];
         $tracking_url = $url . (strpos($url, '?') === FALSE ? '?' : '&') . buildAdTrackingQuery($copy);
         $url_shorten = getShortenUrl($tracking_url);
         self::create(['copy' => $copy, 'url' => $url, 'url_shorten' => $url_shorten]);
     } else {
         $generalAdObj = self::find($attr['id']);
         if (!empty($generalAdObj)) {
             $generalAdObj->is_active = $attr['is_active'];
             $generalAdObj->save();
         }
     }
     // reset cache
     self::setCache(true);
 }
예제 #2
0
파일: Ad.php 프로젝트: lucy-udalykh/samples
 private static function requestAdDatailsCache($dma_code, $ad_id, $job_id)
 {
     $sql = "SELECT a.id, a.dma_code, a.copy, aj.job_id\n  \t\t\t   FROM ad_jobs aj, ads a\n  \t\t\t  WHERE aj.ad_id = a.id\n   \t\t\t\tAND a.is_active = 1\n  \t\t\t\tAND aj.job_id = {$job_id}\n  \t\t\t\tAND a.dma_code = {$dma_code}\n  \t\t\t\tAND a.id = {$ad_id}";
     $ads = DB::select($sql);
     foreach ($ads as $ad) {
         $cache_data['copy'] = $ad->copy;
         $cache_data['url'] = getShortenUrl('http://diversityonecareers.com/job/' . $ad->job_id . '?' . buildAdTrackingQuery($ad->copy));
         $cache_key = self::getAdDetailsCacheKey($dma_code, $ad_id, $job_id);
         Redis::hmset($cache_key, $cache_data);
     }
 }