Esempio n. 1
0
 public function on_uninstall()
 {
     global $wpdb;
     delete_option(WP_CLANWARS_CATEGORY);
     delete_option(WP_CLANWARS_DEFAULTCSS);
     \WP_Clanwars\ACL::destroy();
     $tables = array();
     array_push(\WP_Clanwars\Games::table());
     array_push(\WP_Clanwars\Maps::table());
     array_push(\WP_Clanwars\Rounds::table());
     array_push(\WP_Clanwars\Matches::table());
     array_push(\WP_Clanwars\Teams::table());
     foreach ($tables as $table) {
         $wpdb->query("DROP TABLE `{$table}`");
     }
 }
Esempio n. 2
0
 static function most_popular_countries()
 {
     global $wpdb;
     static $cache = false;
     $limit = 10;
     if ($cache !== false) {
         return $cache;
     }
     $teams_table = \WP_Clanwars\Teams::table();
     $matches_table = \WP_Clanwars\Matches::table();
     $query = $wpdb->prepare("(SELECT t1.country, COUNT(t2.id) AS cnt\n\t\t\tFROM {$teams_table} AS t1, {$matches_table} AS t2\n\t\t\tWHERE t1.id = t2.team1\n\t\t\tGROUP BY t1.country\n\t\t\tLIMIT %d)\n\t\t\tUNION\n\t\t\t(SELECT t1.country, COUNT(t2.id) AS cnt\n\t\t\tFROM {$teams_table} AS t1, {$matches_table} AS t2\n\t\t\tWHERE t1.id = t2.team2\n\t\t\tGROUP BY t1.country\n\t\t\tLIMIT %d)\n\t\t\tORDER BY cnt DESC\n\t\t\tLIMIT %d", $limit, $limit, $limit);
     $cache = $wpdb->get_results($query, ARRAY_A);
     return $cache;
 }