function testCreate() { $this->item->giag_name = 'Test Ad Group'; $this->item->giag_campaign_id = 1; $this->item->giag_destination_url = "http://www.sdfsdaf.com/asfg/csvbdfb"; $this->item->giag_display_url = DISPLAY_URL; $this->assertTrue($this->item->save()); $this->db->executeSQL("SELECT * FROM google_image_ad_groups WHERE giag_id = " . $this->item->giag_id, $resultArry, $rowsAffected); foreach ($resultArry[0] as $key => $val) { $this->assertEqual($val, $this->item->{$key}); } }
$campaign->save(); $db->executeSQL("SELECT keyword_id, keyword, occurs, word_count, source_keyword_id , c.l_image, c.l_make, c.l_color, c.l_model\n\t\t\t\t\tFROM m2m_keywords_to_niches a \n\t\t\t\t\tleft join keywords b using(keyword_id)\n\t\t\t\t\tLEFT JOIN {$table} c USING(keyword_id)\nWHERE c.l_image!= '' and niche_id = " . NICHE . " and occurs > " . GROUP_SIZE . " and word_count > 2 order by word_count desc, occurs desc", $resultArry, $rowsAffected); $total = $rowsAffected; $left = $total; echo $total . " keywords\r\n"; $start_time = date('U'); $kws = array(); $keyword = new Keyword($db); $fp = fopen("../output/" . str_replace(" ", "_", $campaign->ga_campaign_name) . ".csv", "w+"); fputs($fp, "Campaign,Daily Budget,Language,Location,Proximity Targets,Ad Schedule,Ad Group,Max CPC,Keyword Type,Keyword,Image,Ad Name,Image Size,Display URL,Destination URL\r\n"); foreach ($resultArry as $val) { $adgroup = new GoogleImageAdGroup($db); $adgroup->giag_campaign_id = $campaign->ga_campaign_id; $adgroup->giag_display_url = DISPLAY_URL; $adgroup->buildDestinationUrl($val); $adgroup->save(); $adgroup->giag_name = "Ad " . $adgroup->giag_id . " " . $val['keyword']; $adgroup->save(); $ad = $adgroup->buildAds("http://images.kabel.co.il/photo/?url=" . $val['l_image'] . "§ion=realestate"); fputs($fp, "{$campaign->ga_campaign_name},20,iw,IL,,,{$adgroup}," . MAX_CPC . "\r\n"); foreach ($adgroup->ads as $add) { fputs($fp, "{$campaign->ga_campaign_name},,,,,,{$adgroup},,,," . $add->gia_image . "," . $add->gia_name . "," . $add->gia_size . "," . $adgroup->giag_display_url . ",\"" . $adgroup->giag_destination_url . "\"\r\n"); } $tmp = explode(" ", $val['keyword']); $search = ""; foreach ($tmp as $t) { $search .= " and (keyword LIKE '% " . addslashes($t) . " %' or keyword LIKE '% " . addslashes($t) . "' or keyword LIKE '" . addslashes($t) . " %')"; } $db->executeSQL("SELECT keyword_id, keyword FROM keywords WHERE 1 {$search}", $resultArry2, $rowsAffected); foreach ($resultArry2 as $r2) { if (!in_array($r2['keyword'], $kws)) {