PluginProbe
WP Smart Import : Import any XML File to WordPress / trunk
WP Smart Import : Import any XML File to WordPress vtrunk
2.0.0 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6
wp-smart-import / table / schema.php

schema.php in WP Smart Import : Import any XML File to WordPress trunk, at table/schema.php

63 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin database schema
4 * WARNING:
5 * dbDelta() doesn't like empty lines in schema string, so don't put them there;
6 * WPDB doesn't like NULL values so better not to have them in the tables;
7 */
8
9 /**
10 * The database character collate.
11 * @var string
12 * @global string
13 * @name $charset_collate
14 */
15
16 // Declare these as global in case schema.php is included from a function.
17 global $wpdb;
18 $prefix = $wpdb->prefix."wpsi_";
19 $charset_collate = $wpdb->get_charset_collate();
20 $table = $prefix."imports";
21 $main_tab = $table;
22 $sql = "CREATE TABLE $table (
23 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
24 name VARCHAR(255) NOT NULL DEFAULT '',
25 feed_type ENUM('xml','csv','zip','gz','') NOT NULL DEFAULT '',
26 file_path TEXT,
27 options LONGTEXT,
28 post_data LONGTEXT,
29 post_type VARCHAR(255),
30 unique_key VARCHAR(255) NOT NULL DEFAULT '',
31 root_element VARCHAR(255) DEFAULT '',
32 count BIGINT(20) NOT NULL DEFAULT 0,
33 created BIGINT(20) NOT NULL DEFAULT 0,
34 updated BIGINT(20) NOT NULL DEFAULT 0,
35 failed BIGINT(20) NOT NULL DEFAULT 0,
36 created_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
37 last_activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
38 PRIMARY KEY (id)
39 ) $charset_collate;";
40
41 $table = $prefix."posts";
42 $sql .="CREATE TABLE $table (
43 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
44 post_id BIGINT(20) UNSIGNED NOT NULL,
45 import_id BIGINT(20) UNSIGNED NOT NULL,
46 unique_key TEXT,
47 PRIMARY KEY (id),
48 FOREIGN KEY (import_id) REFERENCES $main_tab(id) ON DELETE CASCADE ON UPDATE CASCADE
49 ) $charset_collate;";
50
51 $table = $prefix."files";
52 $sql .="CREATE TABLE $table (
53 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
54 name VARCHAR(255) NOT NULL DEFAULT '',
55 file_name VARCHAR(255) NOT NULL DEFAULT '',
56 file_path TEXT,
57 folder_name TEXT,
58 created_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
59 updated_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
60 PRIMARY KEY (id)
61 ) $charset_collate;";
62 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
63 dbDelta($sql);