Database.php
973 Bytes
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
<?php
namespace AC\Plugin\Install;
use AC;
final class Database implements AC\Plugin\Install {
const TABLE = 'admin_columns';
public function install() {
$this->create_database();
}
private function create_database() {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $this->get_schema() );
}
private function get_schema() {
global $wpdb;
$collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . self::TABLE;
$table = "
CREATE TABLE {$table_name} (
id bigint(20) unsigned NOT NULL auto_increment,
list_id varchar(20) NOT NULL default '',
list_key varchar(100) NOT NULL default '',
title varchar(255) NOT NULL default '',
columns mediumtext,
settings mediumtext,
date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
date_modified datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY `list_id` (`list_id`)
) $collate;
";
return $table;
}
}