M_Createtables

The Membership 2 M Createtables function.

Description

M_Createtables(); 

Usage

  1. if ( !function_exists( 'M_Createtables' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'membership-2/app_old/membershipincludes/classes/upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = M_Createtables(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/app_old/membershipincludes/classes/upgrade.php  
  1. function M_Createtables() { 
  2.  
  3. global $wpdb; 
  4.  
  5. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_levels') . "` ( 
  6. `id` bigint(20) NOT NULL auto_increment,  
  7. `level_title` varchar(250) default NULL,  
  8. `level_slug` varchar(250) default NULL,  
  9. `level_active` int(11) default '0',  
  10. `level_count` bigint(20) default '0',  
  11. PRIMARY KEY (`id`) 
  12. );"; 
  13.  
  14. $wpdb->query($sql); 
  15.  
  16. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_relationships') . "` ( 
  17. `rel_id` bigint(20) NOT NULL auto_increment,  
  18. `user_id` bigint(20) default '0',  
  19. `sub_id` bigint(20) default '0',  
  20. `level_id` bigint(20) default '0',  
  21. `startdate` datetime default NULL,  
  22. `updateddate` datetime default NULL,  
  23. `expirydate` datetime default NULL,  
  24. `order_instance` bigint(20) default '0',  
  25. `usinggateway` varchar(50) default 'admin',  
  26. PRIMARY KEY (`rel_id`),  
  27. KEY `user_id` (`user_id`),  
  28. KEY `sub_id` (`sub_id`),  
  29. KEY `usinggateway` (`usinggateway`) 
  30. );"; 
  31.  
  32. $wpdb->query($sql); 
  33.  
  34. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'membership_rules') . "` ( 
  35. `level_id` bigint(20) NOT NULL default '0',  
  36. `rule_ive` varchar(20) NOT NULL default '',  
  37. `rule_area` varchar(20) NOT NULL default '',  
  38. `rule_value` text,  
  39. `rule_order` int(11) default '0',  
  40. PRIMARY KEY (`level_id`, `rule_ive`, `rule_area`),  
  41. KEY `rule_area` (`rule_area`),  
  42. KEY `rule_ive` (`rule_ive`) 
  43. );"; 
  44.  
  45. $wpdb->query($sql); 
  46.  
  47. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscriptions') . "` ( 
  48. `id` bigint(20) NOT NULL auto_increment,  
  49. `sub_name` varchar(200) default NULL,  
  50. `sub_active` int(11) default '0',  
  51. `sub_public` int(11) default '0',  
  52. `sub_count` bigint(20) default '0',  
  53. `sub_description` text,  
  54. `sub_pricetext` varchar(200) DEFAULT NULL,  
  55. PRIMARY KEY (`id`) 
  56. );"; 
  57.  
  58. $wpdb->query($sql); 
  59.  
  60. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscriptions_levels') . "` ( 
  61. `sub_id` bigint(20) default NULL,  
  62. `level_id` bigint(20) default NULL,  
  63. `level_period` int(11) default NULL,  
  64. `sub_type` varchar(20) default NULL,  
  65. `level_price` decimal(11, 2) default '0.00',  
  66. `level_currency` varchar(5) default NULL,  
  67. `level_order` bigint(20) default '0',  
  68. `level_period_unit` varchar(1) default 'd',  
  69. KEY `sub_id` (`sub_id`),  
  70. KEY `level_id` (`level_id`) 
  71. );"; 
  72.  
  73. $wpdb->query($sql); 
  74.  
  75. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscription_transaction') . "` ( 
  76. `transaction_ID` bigint(20) unsigned NOT NULL auto_increment,  
  77. `transaction_subscription_ID` bigint(20) NOT NULL default '0',  
  78. `transaction_user_ID` bigint(20) NOT NULL default '0',  
  79. `transaction_sub_ID` bigint(20) default '0',  
  80. `transaction_paypal_ID` varchar(30) default NULL,  
  81. `transaction_payment_type` varchar(20) default NULL,  
  82. `transaction_stamp` bigint(35) NOT NULL default '0',  
  83. `transaction_total_amount` bigint(20) default NULL,  
  84. `transaction_currency` varchar(35) default NULL,  
  85. `transaction_status` varchar(35) default NULL,  
  86. `transaction_duedate` date default NULL,  
  87. `transaction_gateway` varchar(50) default NULL,  
  88. `transaction_note` text,  
  89. `transaction_expires` datetime default NULL,  
  90. PRIMARY KEY (`transaction_ID`),  
  91. KEY `transaction_gateway` (`transaction_gateway`),  
  92. KEY `transaction_subscription_ID` (`transaction_subscription_ID`) 
  93. );"; 
  94.  
  95. $wpdb->query($sql); 
  96.  
  97. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'urlgroups') . "` ( 
  98. `id` bigint(20) NOT NULL auto_increment,  
  99. `groupname` varchar(250) default NULL,  
  100. `groupurls` text,  
  101. `isregexp` int(11) default '0',  
  102. `stripquerystring` int(11) default '0',  
  103. PRIMARY KEY (`id`) 
  104. );"; 
  105.  
  106. $wpdb->query($sql); 
  107.  
  108. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'communications') . "` ( 
  109. `id` bigint(11) NOT NULL auto_increment,  
  110. `subject` varchar(250) default NULL,  
  111. `message` text,  
  112. `periodunit` int(11) default NULL,  
  113. `periodtype` varchar(5) default NULL,  
  114. `periodprepost` varchar(5) default NULL,  
  115. `lastupdated` timestamp NULL default NULL on update CURRENT_TIMESTAMP,  
  116. `active` int(11) default '0',  
  117. `periodstamp` bigint(20) default '0',  
  118. PRIMARY KEY (`id`) 
  119. );"; 
  120.  
  121. $wpdb->query($sql); 
  122.  
  123. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'pings') . "` ( 
  124. `id` bigint(20) NOT NULL auto_increment,  
  125. `pingname` varchar(250) default NULL,  
  126. `pingurl` varchar(250) default NULL,  
  127. `pinginfo` text,  
  128. `pingtype` varchar(10) default NULL,  
  129. PRIMARY KEY (`id`) 
  130. );"; 
  131.  
  132. $wpdb->query($sql); 
  133.  
  134. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'ping_history') . "` ( 
  135. `id` bigint(20) NOT NULL auto_increment,  
  136. `ping_id` bigint(20) default NULL,  
  137. `ping_sent` timestamp NULL default NULL,  
  138. `ping_info` text,  
  139. `ping_return` text,  
  140. PRIMARY KEY (`id`),  
  141. KEY `ping_id` (`ping_id`) 
  142. );"; 
  143.  
  144. $wpdb->query($sql); 
  145.  
  146. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'levelmeta') . "` ( 
  147. `id` bigint(20) NOT NULL auto_increment,  
  148. `level_id` bigint(20) default NULL,  
  149. `meta_key` varchar(250) default NULL,  
  150. `meta_value` text,  
  151. `meta_stamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,  
  152. PRIMARY KEY (`id`),  
  153. UNIQUE KEY `level_id` (`level_id`, `meta_key`) 
  154. );"; 
  155.  
  156. $wpdb->query($sql); 
  157.  
  158. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'subscriptionmeta') . "` ( 
  159. `id` bigint(20) NOT NULL auto_increment,  
  160. `sub_id` bigint(20) default NULL,  
  161. `meta_key` varchar(250) default NULL,  
  162. `meta_value` text,  
  163. `meta_stamp` timestamp NULL default NULL on update CURRENT_TIMESTAMP,  
  164. PRIMARY KEY (`id`),  
  165. UNIQUE KEY `sub_id` (`sub_id`, `meta_key`) 
  166. );"; 
  167.  
  168. $wpdb->query($sql); 
  169.  
  170. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'member_payments') . "` ( 
  171. `id` bigint(11) NOT NULL auto_increment,  
  172. `member_id` bigint(20) default NULL,  
  173. `sub_id` bigint(20) default NULL,  
  174. `level_id` bigint(20) default NULL,  
  175. `level_order` int(11) default NULL,  
  176. `paymentmade` datetime default NULL,  
  177. `paymentexpires` datetime default NULL,  
  178. PRIMARY KEY (`id`) 
  179. );"; 
  180.  
  181. $wpdb->query($sql); 
  182.  
  183. $sql = "CREATE TABLE IF NOT EXISTS `" . membership_db_prefix($wpdb, 'coupons') . "` ( 
  184. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,  
  185. `site_id` bigint(20) DEFAULT '0',  
  186. `couponcode` varchar(250) DEFAULT NULL,  
  187. `discount` decimal(11, 2) DEFAULT '0.00',  
  188. `discount_type` varchar(5) DEFAULT NULL,  
  189. `discount_currency` varchar(5) DEFAULT NULL,  
  190. `coupon_startdate` datetime DEFAULT NULL,  
  191. `coupon_enddate` datetime DEFAULT NULL,  
  192. `coupon_sub_id` bigint(20) DEFAULT '0',  
  193. `coupon_uses` int(11) DEFAULT '0',  
  194. `coupon_used` int(11) DEFAULT '0',  
  195. `coupon_apply_to` varchar(20) DEFAULT NULL,  
  196. PRIMARY KEY (`id`),  
  197. KEY `couponcode` (`couponcode`) 
  198. )"; 
  199.  
  200. $wpdb->query( $sql ); 
  201.