Ok, I have two questions.
1) My plugin has this code.
// create database
global $wpdb;
if($wpdb->get_var("SHOW TABLES LIKE '".CP_DB."'") != CP_DB || (int) get_option('cp_db_version') < 1.3) {
$sql = "CREATE TABLE " . CP_DB . " (
id bigint(20) NOT NULL AUTO_INCREMENT,
uid bigint(20) NOT NULL,
type VARCHAR(256) NOT NULL,
data TEXT NOT NULL,
points bigint(20) NOT NULL,
timestamp bigint(20) NOT NULL,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
add_option("cp_db_version", 1.3);
}
The above code will be executed when i activate the plugin.
But i need a global table to store the global points.
This is my gloabl points table code.
sql = "CREATE TABLE " . CP_GLOBALDB . " (
id bigint(20) NOT NULL AUTO_INCREMENT,
uid bigint(20) NOT NULL,
type VARCHAR(256) NOT NULL,
data TEXT NOT NULL,
points bigint(20) NOT NULL,
timestamp bigint(20) NOT NULL,
UNIQUE KEY id (id)
);";
Global table should be created only in the main site. How to create that global table when the plugin activated? I mean what is the php code?
2) How to query that main site global table from sub site?