Пример #1
0
function membership_newsstreamcreatetables($installed = false)
{
    global $wpdb;
    require_once membership_dir('membershipincludes/classes/upgrade.php');
    $charset_collate = M_get_charset_collate();
    $table = 'membership_news';
    $row = $wpdb->get_results($wpdb->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS\n\t\tWHERE table_name = %s and column_name='id' LIMIT 1", membership_db_prefix($wpdb, $table, false)));
    if (!empty($row)) {
        $sql = $wpdb->prepare("RENAME TABLE %s TO %s;", membership_db_prefix($wpdb, $table, false), membership_db_prefix($wpdb, $table));
        $sql = str_replace("'", '`', $sql);
        $wpdb->query($sql);
    } else {
        // Added for RC
        $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_news') . "` (\n\t\t\t  `id` bigint(11) NOT NULL auto_increment,\n\t\t\t  `newsitem` text,\n\t\t\t  `newsdate` datetime default NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t) {$charset_collate};";
        $wpdb->query($sql);
    }
}
Пример #2
0
function M_Create_single_table($name)
{
    global $wpdb;
    $charset_collate = M_get_charset_collate();
    switch ($name) {
        case membership_db_prefix($wpdb, 'membership_levels'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_levels') . "` (\n\t\t\t\t\t  `id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t  `level_title` varchar(250) default NULL,\n\t\t\t\t\t  `level_slug` varchar(250) default NULL,\n\t\t\t\t\t  `level_active` int(11) default '0',\n\t\t\t\t\t  `level_count` bigint(20) default '0',\n\t\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'membership_relationships'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_relationships') . "` (\n\t\t\t\t\t  \t`rel_id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t\t`user_id` bigint(20) default '0',\n\t\t\t\t\t\t`sub_id` bigint(20) default '0',\n\t\t\t\t\t\t`level_id` bigint(20) default '0',\n\t\t\t\t\t\t`startdate` datetime default NULL,\n\t\t\t\t\t\t`updateddate` datetime default NULL,\n\t\t\t\t\t\t`expirydate` datetime default NULL,\n\t\t\t\t\t\t`order_instance` bigint(20) default '0',\n\t\t\t\t\t\t`usinggateway` varchar(50) default 'admin',\n\t\t\t\t\t\tPRIMARY KEY  (`rel_id`),\n\t\t\t\t\t\tKEY `user_id` (`user_id`),\n\t\t\t\t\t\tKEY `sub_id` (`sub_id`),\n\t\t\t\t\t\tKEY `usinggateway` (`usinggateway`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'membership_rules'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_rules') . "` (\n\t\t\t\t\t  `level_id` bigint(20) NOT NULL default '0',\n\t\t\t\t\t  `rule_ive` varchar(20) NOT NULL default '',\n\t\t\t\t\t  `rule_area` varchar(20) NOT NULL default '',\n\t\t\t\t\t  `rule_value` text,\n\t\t\t\t\t  `rule_order` int(11) default '0',\n\t\t\t\t\t  PRIMARY KEY  (`level_id`,`rule_ive`,`rule_area`),\n\t\t\t\t\t  KEY `rule_area` (`rule_area`),\n\t\t\t\t\t  KEY `rule_ive` (`rule_ive`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'subscriptions'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscriptions') . "` (\n\t\t\t\t\t  `id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t  `sub_name` varchar(200) default NULL,\n\t\t\t\t\t  `sub_active` int(11) default '0',\n\t\t\t\t\t  `sub_public` int(11) default '0',\n\t\t\t\t\t  `sub_count` bigint(20) default '0',\n\t\t\t\t\t  `sub_description` text,\n\t\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'subscriptions_levels'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscriptions_levels') . "` (\n\t\t\t\t\t  \t`sub_id` bigint(20) default NULL,\n\t\t\t\t\t\t`level_id` bigint(20) default NULL,\n\t\t\t\t\t\t`level_period` int(11) default NULL,\n\t\t\t\t\t\t`sub_type` varchar(20) default NULL,\n\t\t\t\t\t\t`level_price` decimal(11,2) default '0.00',\n\t\t\t\t\t\t`level_currency` varchar(5) default NULL,\n\t\t\t\t\t\t`level_order` bigint(20) default '0',\n\t\t\t\t\t\t`level_period_unit` varchar(1) default 'd',\n\t\t\t\t\t\tKEY `sub_id` (`sub_id`),\n\t\t\t\t\t\tKEY `level_id` (`level_id`)\n\t\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'subscription_transaction'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscription_transaction') . "` (\n\t\t\t\t\t  `transaction_ID` bigint(20) unsigned NOT NULL auto_increment,\n\t\t\t\t\t  `transaction_subscription_ID` bigint(20) NOT NULL default '0',\n\t\t\t\t\t  `transaction_user_ID` bigint(20) NOT NULL default '0',\n\t\t\t\t\t  `transaction_sub_ID` bigint(20) default '0',\n\t\t\t\t\t  `transaction_paypal_ID` varchar(30) default NULL,\n\t\t\t\t\t  `transaction_payment_type` varchar(20) default NULL,\n\t\t\t\t\t  `transaction_stamp` bigint(35) NOT NULL default '0',\n\t\t\t\t\t  `transaction_total_amount` bigint(20) default NULL,\n\t\t\t\t\t  `transaction_currency` varchar(35) default NULL,\n\t\t\t\t\t  `transaction_status` varchar(35) default NULL,\n\t\t\t\t\t  `transaction_duedate` date default NULL,\n\t\t\t\t\t  `transaction_gateway` varchar(50) default NULL,\n\t\t\t\t\t  `transaction_note` text,\n\t\t\t\t\t  `transaction_expires` datetime default NULL,\n\t\t\t\t\t  PRIMARY KEY  (`transaction_ID`),\n\t\t\t\t\t  KEY `transaction_gateway` (`transaction_gateway`),\n\t\t\t\t\t  KEY `transaction_subscription_ID` (`transaction_subscription_ID`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'urlgroups'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'urlgroups') . "` (\n\t\t\t\t\t  `id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t  `groupname` varchar(250) default NULL,\n\t\t\t\t\t  `groupurls` text,\n\t\t\t\t\t  `isregexp` int(11) default '0',\n\t\t\t\t\t  `stripquerystring` int(11) default '0',\n\t\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'communications'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'communications') . "` (\n\t\t\t\t\t  `id` bigint(11) NOT NULL auto_increment,\n\t\t\t\t\t  `sub_id` bigint(20) DEFAULT NULL,\n\t\t\t\t\t  `subject` varchar(250) default NULL,\n\t\t\t\t\t  `message` text,\n\t\t\t\t\t  `periodunit` int(11) default NULL,\n\t\t\t\t\t  `periodtype` varchar(5) default NULL,\n\t\t\t\t\t  `periodprepost` varchar(5) default NULL,\n\t\t\t\t\t  `lastupdated` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n\t\t\t\t\t  `active` int(11) default '0',\n\t\t\t\t\t  `periodstamp` bigint(20) default '0',\n\t\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'pings'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'pings') . "` (\n\t\t\t\t\t  \t`id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t\t`pingname` varchar(250) default NULL,\n\t\t\t\t\t\t`pingurl` varchar(250) default NULL,\n\t\t\t\t\t\t`pinginfo` text,\n\t\t\t\t\t\t`pingtype` varchar(10) default NULL,\n\t\t\t\t\t\tPRIMARY KEY  (`id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'ping_history'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'ping_history') . "` (\n\t\t\t\t\t  \t`id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t\t`ping_id` bigint(20) default NULL,\n\t\t\t\t\t\t`ping_sent` timestamp NULL default NULL,\n\t\t\t\t\t\t`ping_info` text,\n\t\t\t\t\t\t`ping_return` text,\n\t\t\t\t\t\tPRIMARY KEY  (`id`),\n\t\t\t\t\t\tKEY `ping_id` (`ping_id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'levelmeta'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'levelmeta') . "` (\n\t\t\t\t\t  \t`id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t\t`level_id` bigint(20) default NULL,\n\t\t\t\t\t\t`meta_key` varchar(250) default NULL,\n\t\t\t\t\t\t`meta_value` text,\n\t\t\t\t\t\t`meta_stamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n\t\t\t\t\t\tPRIMARY KEY  (`id`),\n\t\t\t\t\t\tUNIQUE KEY `level_id` (`level_id`,`meta_key`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'subscriptionmeta'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscriptionmeta') . "` (\n\t\t\t\t\t  \t`id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t\t`sub_id` bigint(20) default NULL,\n\t\t\t\t\t\t`meta_key` varchar(250) default NULL,\n\t\t\t\t\t\t`meta_value` text,\n\t\t\t\t\t\t`meta_stamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,\n\t\t\t\t\t\tPRIMARY KEY  (`id`),\n\t\t\t\t\t\tUNIQUE KEY `sub_id` (`sub_id`,`meta_key`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'member_payments'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'member_payments') . "` (\n\t\t\t\t\t  \t`id` bigint(11) NOT NULL auto_increment,\n\t\t\t\t\t\t`member_id` bigint(20) default NULL,\n\t\t\t\t\t\t`sub_id` bigint(20) default NULL,\n\t\t\t\t\t\t`level_id` bigint(20) default NULL,\n\t\t\t\t\t\t`level_order` int(11) default NULL,\n\t\t\t\t\t\t`paymentmade` datetime default NULL,\n\t\t\t\t\t\t`paymentexpires` datetime default NULL,\n\t\t\t\t\t\tPRIMARY KEY  (`id`)\n\t\t\t\t\t) {$charset_collate};";
            break;
        case membership_db_prefix($wpdb, 'coupons'):
            $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'coupons') . "` (\n\t\t\t\t\t  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t  `site_id` bigint(20) DEFAULT '0',\n\t\t\t\t\t  `couponcode` varchar(250) DEFAULT NULL,\n\t\t\t\t\t  `discount` decimal(11,2) DEFAULT '0.00',\n\t\t\t\t\t  `discount_type` varchar(5) DEFAULT NULL,\n\t\t\t\t\t  `discount_currency` varchar(5) DEFAULT NULL,\n\t\t\t\t\t  `coupon_startdate` datetime DEFAULT NULL,\n\t\t\t\t\t  `coupon_enddate` datetime DEFAULT NULL,\n\t\t\t\t\t  `coupon_sub_id` bigint(20) DEFAULT '0',\n\t\t\t\t\t  `coupon_uses` int(11) DEFAULT '0',\n\t\t\t\t\t  `coupon_used` int(11) DEFAULT '0',\n\t\t\t\t\t  `coupon_apply_to` varchar(20) DEFAULT NULL,\n\t\t\t\t\t  PRIMARY KEY (`id`),\n\t\t\t\t\t  KEY `couponcode` (`couponcode`)\n\t\t\t\t\t) {$charset_collate};";
            break;
    }
    $wpdb->query($sql);
}