M_Create_single_table

The Membership 2 M Create single table function.

Description

M_Create_single_table( (string) $name ); 

Parameters (1)

0. $name (string)
The name.

Usage

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

Defined (1)

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

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