/
table_classes.php
137 lines (110 loc) · 3.6 KB
/
table_classes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
class MainFaceTable
{
private $table_version = '0.89';
private $create = '';
function __construct()
{
global $wpdb;
$table_name = $wpdb->prefix . 'pavlov_faces';
$this->create = "CREATE TABLE {$table_name} (
id mediumint(9) NOT NULL AUTO_INCREMENT,
membername tinytext NOT NULL,
title tinytext NOT NULL,
dogname tinytext,
dogbreed tinytext,
mainimage tinytext NOT NULL,
hoverimage tinytext NOT NULL,
signature tinytext,
lefttopic tinytext,
righttopic tinytext,
polaroid1 tinytext,
polaroid2 tinytext,
signature tinytext,
kingdom tinytext,
species tinytext,
phylum tinytext,
stimulant tinytext,
response tinytext,
stimulus tinytext,
location tinytext,
fear tinytext,
threewords tinytext,
ionce tinytext,
couldntlive tinytext,
turnonthe tinytext,
beaker tinytext,
UNIQUE KEY id (id)
)";
$installed_version = get_option('main_face_table');
if(!$installed_version or $installed_version != $this->table_version)
$this->update_tables();
//These also go here:
//add_action('admin_menu', array(&$this, 'admin_menu'));
}
function make_tables()
{
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
if(!require_once(ABSPATH . 'wp-admin/upgrade-functions.php'))
{
die('Foolish samurai warrior has added its own maybe_upgrade* functions');
}
$query = $this->create . $charset_collate . ';';
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($query);
add_option('main_face_table', $this->table_version);
}
function update_tables()
{
$query = $this->create . ';';
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($query);
update_option('main_face_table', $this->table_version);
}
}
class FaceInfoTable
{
private $table_version = '0.8
';
private $create = '';
function __construct()
{
global $wpdb;
$table_name = $wpdb->prefix . 'report_data';
$this->create = "CREATE TABLE $table_name (
dataid mediumint(9) NOT NULL AUTO_INCREMENT,
id mediumint(9),
information mediumtext NOT NULL,
hierarchy mediumint(9),
ranking tinyint(9),
UNIQUE KEY dataid (dataid)
)";
$installed_version = get_option('face_info_table');
if(!$installed_version or $installed_version != $this->table_version)
$this->update_tables();
//These also go here:
//add_action('admin_menu', array(&$this, 'admin_menu'));
}
function make_tables()
{
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
if(!require_once(ABSPATH . 'wp-admin/upgrade-functions.php'))
{
die('Foolish samurai warrior has added its own maybe_upgrade* functions');
}
$query = $this->create . $charset_collate;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($query);
add_option('face_info_table', $this->table_version);
}
function update_tables()
{
$query = $this->create;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($query);
update_option('face_info_table', $this->table_version);
}
}
?>