public function DoScrape($location)
 {
     // scrape a given location
     $this->feed_url = "http://feeds.feedburner.com/groupon" . $this->location_map[$location];
     $data_feed = file_get_contents($this->feed_url);
     $xml = simplexml_load_string($data_feed);
     $channel = $xml->channel;
     // parent:: d($channel);
     // exit();
     foreach ($channel->item as $item) {
         // loop through each item
         parent::SetQuery("SELECT * FROM `aggregate_deal` WHERE deal_url='{$item->link}'");
         $exists = parent::CountDBResults();
         if (!$exists) {
             // deal doesn't exist in the database yet
             //echo $item->title . "<br/>";
             preg_match_all('#\\$[0-9]{1,3}(?:,?[0-9]{3})*(?:\\.[0-9]{2})?#', $item->title, $out);
             $pattern = "/src=[\"']?([^\"']?.*(png|jpg|gif))[\"']?/i";
             preg_match_all($pattern, $item->description, $images);
             parent::SetQuery("INSERT INTO `aggregate_deal`\n\t\t\t\tVALUES ('','','{$location}','','',\n\t\t\t\t'" . addslashes($item->title) . "',\n\t\t\t\t'" . addslashes($item->description) . "',\n\t\t\t\t'{$item->link}',\n\t\t\t\t'" . str_replace("\$", "", $out[0][0]) . "',\n\t\t\t\t'" . str_replace("\$", "", $out[0][1]) . "',\n\t\t\t\t'1',\n\t\t\t\t'" . strtotime('midnight') . "',\n\t\t\t\tnow(),\n\t\t\t\t'{$images[1][0]}','')");
             parent::SimpleQuery();
         }
         parent::SetQuery("SELECT * FROM `aggregate_deal`");
         $results = parent::DoQuery();
         foreach ($results as $result) {
             // loop through each result to see if it has expired, delete it if it has
             $expired = mktime(0, 0, 0, date("m"), date("d", $result["time_added"]) + 1, date("Y"));
             if (time() > $expired) {
                 parent::SetQuery("DELETE FROM `aggregate_deal` WHERE aggregate_deal_id='{$result["deal_id"]}'");
                 parent::SimpleQuery();
             }
         }
     }
 }
 public function getDealsMissingInfo()
 {
     parent::SetQuery("SELECT aggregate_deal_id,  deal_url FROM aggregate_deal WHERE aggregate_deal_source_id = 1");
     $arrays = parent::DoQuery();
     return $arrays;
 }