Пример #1
0
$query = 'SELECT * FROM ' . DB_FACEBOOK_PREFIX . 'country_3_1 ORDER BY 1;';
$que = db_query($query, array());
$country_date_last_update = get_country_date_last_update(mysql_num_rows($que));
while ($country = mysql_fetch_assoc($que)) {
    $id_country = $country['id_country'];
    $code = $country['code'];
    $name = $country['nombre'];
    $name_en = $country['name'];
    $abbreviation = !empty($country['abbreviation']) ? $country['abbreviation'] : 'NULL';
    $slug = $country['slug'];
    $idiom = !empty($country['idiom']) ? $country['idiom'] : 'NULL';
    $id_continent = $country['id_continent'];
    $supports_region = $country['supports_region'];
    $supports_city = $country['supports_city'];
    $audience = get_country_audience($id_country, $country_date_last_update);
    $aux_audience_history = get_audience_history($id_country, $country_date_last_update, 380);
    $audience_down_360 = $aux_audience_history['accumulate_down_360'];
    unset($aux_audience_history['accumulate_down_360']);
    $audience_history = json_encode($aux_audience_history);
    $audience_grow_90 = getCrecimiento($id_country, 'user', $country_date_last_update, 90);
    $audience_grow_180 = getCrecimiento($id_country, 'user', $country_date_last_update, 180);
    $audience_grow_270 = getCrecimiento($id_country, 'user', $country_date_last_update, 270);
    $audience_grow_360 = getCrecimiento($id_country, 'user', $country_date_last_update, 360);
    $audience_female_grow_30 = getCrecimiento($id_country, 'female', $country_date_last_update, 30);
    $audience_male_grow_30 = getCrecimiento($id_country, 'male', $country_date_last_update, 30);
    $general_ranking = 'NULL';
    $query = 'SELECT id_country FROM ' . DB_RESULTS_PREFIX . 'facebook_countries WHERE id_country = $10;';
    $que_country = db_query_table_results($query, array($id_country));
    if ($row = mysql_fetch_assoc($que_country)) {
        $query = "UPDATE " . DB_RESULTS_PREFIX . "facebook_countries SET \n                                                code = '\$10',\n                                                name = '\$11',\n                                                name_en = '\$12',\n                                                abbreviation = " . ($abbreviation != "NULL" ? "'\$13'" : "\$13") . ",\n                                                slug = '\$14',\n                                                idiom = " . ($idiom != "NULL" ? "'\$15'" : "\$15") . ",\n                                                id_continent = \$16,\n                                                supports_region = \$17,\n                                                supports_city = \$18,\n                                                total_user = \$19,\n                                                total_female = \$20,\n                                                total_male = \$21,\n                                                audience_history = '\$22',\n                                                audience_grow_90 = \$23,\n                                                audience_grow_180 = \$24,\n                                                audience_grow_270 = \$25,\n                                                audience_grow_360 = \$26,\n                                                audience_down_360 = \$27,\n                                                audience_female_grow_30 = \$28,\n                                                audience_male_grow_30 = \$29,\n                                                updated_at = NOW()\n                                                \n                                                WHERE id_country = \$30;";
        $values = array($code, $name, $name_en, $abbreviation, $slug, $idiom, $id_continent, $supports_region, $supports_city, $audience['total_user'], $audience['total_female'], $audience['total_male'], $audience_history, $audience_grow_90, $audience_grow_180, $audience_grow_270, $audience_grow_360, $audience_down_360, $audience_female_grow_30, $audience_male_grow_30, $id_country);
Пример #2
0
$countries = array();
$query = 'SELECT * FROM facebook_country_3_1 ORDER BY 1;';
$que = db_query($query, array());
$country_date_last_update = get_country_date_last_update(mysql_num_rows($que));
while ($country = mysql_fetch_assoc($que)) {
    $id_country = $country['id_country'];
    $code = $country['code'];
    $name = $country['nombre'];
    $name_en = $country['name'];
    $abbreviation = !empty($country['abbreviation']) ? $country['abbreviation'] : 'NULL';
    $idiom = $country['habla_hispana'] == 1 ? 'es' : 'NULL';
    $id_continent = $country['id_continent'];
    $supports_region = $country['supports_region'];
    $supports_city = $country['supports_city'];
    $audience = get_country_audience($id_country, $country_date_last_update);
    $audience_history = json_encode(get_audience_history($id_country, $country_date_last_update, 180));
    $audience_grow_1 = getCrecimiento($id_country, $country_date_last_update, 1);
    $audience_grow_7 = getCrecimiento($id_country, $country_date_last_update, 7);
    $audience_grow_30 = getCrecimiento($id_country, $country_date_last_update, 30);
    $audience_grow_60 = getCrecimiento($id_country, $country_date_last_update, 60);
    $audience_grow_90 = getCrecimiento($id_country, $country_date_last_update, 90);
    $audience_grow_180 = getCrecimiento($id_country, $country_date_last_update, 180);
    $general_ranking = 'NULL';
    $query = 'SELECT id_country FROM facebook_countries WHERE id_country = $10;';
    $que_country = db_query_table_results($query, array($id_country));
    if ($row = mysql_fetch_assoc($que_country)) {
        $query = "UPDATE facebook_countries SET \n                                                code = '\$10',\n                                                name = '\$11',\n                                                name_en = '\$12',\n                                                abbreviation = " . ($abbreviation != "NULL" ? "'\$13'" : "\$13") . ",\n                                                idiom = " . ($idiom != "NULL" ? "'\$14'" : "\$14") . ",\n                                                id_continent = \$15,\n                                                supports_region = \$16,\n                                                supports_city = \$17,\n                                                total_user = \$18,\n                                                total_female = \$19,\n                                                total_male = \$20,\n                                                audience_history = '\$21',\n                                                audience_grow_1 = \$22,\n                                                audience_grow_7 = \$23,\n                                                audience_grow_30 = \$24,\n                                                audience_grow_60 = \$25,\n                                                audience_grow_90 = \$26,\n                                                audience_grow_180 = \$27,\n                                                updated_at = NOW()\n                                                \n                                                WHERE id_country = \$28;";
        $values = array($code, $name, $name_en, $abbreviation, $idiom, $id_continent, $supports_region, $supports_city, $audience['total_user'], $audience['total_female'], $audience['total_male'], $audience_history, $audience_grow_1, $audience_grow_7, $audience_grow_30, $audience_grow_60, $audience_grow_90, $audience_grow_180, $id_country);
        $res = db_query_table_results($query, $values, 1);
    } else {
        $query = "INSERT INTO facebook_countries VALUES(\$10, '\$11', '\$12', '\$13', " . ($abbreviation != "NULL" ? "'\$14'" : "\$14") . ", " . ($idiom != "NULL" ? "'\$15'" : "\$15") . ", \$16, \$17, \$18, \$19, \$20, \$21, '\$22', \$23, \$24, \$25, \$26, \$27, \$28, \$29, NOW());";