public function insert($url, $title, $img_url, $source_id, $region_id, $price, $value, $time_added, $vendor_name, $addresses, $description) { parent::SetQuery("SELECT * FROM `aggregate_deal` WHERE deal_url='{$url}'"); $exists = parent::CountDBResults(); if (!$exists) { parent::SetQuery("INSERT INTO `aggregate_deal`\n\t\t\t\t\t(\n\t\t\t\t\taggregate_deal_region_id,\n\t\t\t\t\ttitle, \n\t\t\t\t\tdeal_url, \n\t\t\t\t\timg_url,\n\t\t\t\t\taggregate_deal_source_id,\n\t\t\t\t\tdate,\n\t\t\t\t\tprice,\n\t\t\t\t\tvalue,\n\t\t\t\t\ttime_added,\n\t\t\t\t\tvendor_name,\n\t\t\t\t\tdescription\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t'{$region_id}',\n\t\t\t\t\t'" . addslashes($title) . "',\n\t\t\t\t\t'{$url}',\n\t\t\t\t\t'{$img_url}',\n\t\t\t\t\t{$source_id},\n\t\t\t\t\tnow(),\n\t\t\t\t\t{$price},\n\t\t\t\t\t{$value},\n\t\t\t\t\t{$time_added},\n\t\t\t\t\t'{$vendor_name}',\n\t\t\t\t\t'{$description}'\n\t\t\t\t\t)"); $mysql_insert_id = parent::InsertQuery(); if ($vendor_name != "-") { foreach ($addresses as $address) { foreach ($address as $k => $v) { if ($k == 'address') { $address = $v; } if ($k == 'city') { $city = $v; } if ($k == 'state') { $state = $v; } if ($k == 'zipcode') { $zipcode = $v; } if ($k == 'latitude') { $latitude = $v; } if ($k == 'longitude') { $longitude = $v; } } $address = addslashes($address); parent::SetQuery("INSERT INTO aggregate_deal_location (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taddress_all,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taddress, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\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\t\t\t\t\t\t\t\t\t\t\t\t'{$longitude}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$mysql_insert_id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) "); $mysql_insert_id = parent::InsertQuery(); } } else { $mysql_insert_id = 0; } } }
public function insertMissingInfo($address, $aggregate_deal_id) { parent::SetQuery("INSERT INTO aggregate_deal_location (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taddress_all,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taggregate_deal_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalues(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$address}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$aggregate_deal_id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) "); $mysql_insert_id = parent::InsertQuery(); }