· 7 years ago · Oct 17, 2018, 02:12 AM
1 $table_name = $this->wpdb->prefix . 'predictions';
2 if($this->wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name)
3 {
4 $sql = "
5 CREATE TABLE IF NOT EXISTS `{$table_name}` (
6 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
7 `user_id` INT NOT NULL ,
8 `year` INT NOT NULL ,
9 `season` BOOLEAN NOT NULL ,
10 `step1_most_valuable_player` VARCHAR(100) ,
11 `step1_off_player_of_the_year` VARCHAR(100) ,
12 `step1_def_player_of_the_year` VARCHAR(100) ,
13 `step1_off_rookie_of_the_year` VARCHAR(100) ,
14 `step1_def_rookie_of_the_year` VARCHAR(100) ,
15 `step1_coach_of_the_year` VARCHAR(100) ,
16 `step1_highest_qb_rating` VARCHAR(100) ,
17 `step1_rushing_title` VARCHAR(100) ,
18 `step1_most_receptions` VARCHAR(100) ,
19 `step1_sack_leader` VARCHAR(100) ,
20 `step1_breakout_player` VARCHAR(100) ,
21 `step1_star_subpar_season` VARCHAR(100) ,
22 `step1_game_of_the_year` VARCHAR(100) ,
23 `step1_team_best_record` VARCHAR(100) ,
24 `step1_team_worst_record` VARCHAR(100) ,
25 `step1_best_team_to_not_make_playoffs` VARCHAR(100) ,
26 `step2_afc_west` VARCHAR(100) ,
27 `step2_afc_north` VARCHAR(100) ,
28 `step2_afc_south` VARCHAR(100) ,
29 `step2_afc_east` VARCHAR(100) ,
30 `step2_nfc_west` VARCHAR(100) ,
31 `step2_nfc_north` VARCHAR(100) ,
32 `step2_nfc_south` VARCHAR(100) ,
33 `step2_nfc_east` VARCHAR(100) ,
34 'step3_afc_playoff' VARCHAR(200) ,
35 'step3_nfc_playoff' VARCHAR(200) ,
36 'step3_superbowl_champion' VARCHAR(200) ,
37 ) ENGINE=MyISAM {$this->charsetCollate}";
38 $this->wpdb->query($sql);
39 if($e = mysql_error())
40 throw new Exception($e);
41 }