M_add_possible_missing_fields

The Membership 2 M add possible missing fields function.

Description

M_add_possible_missing_fields( $table, (string) $name, $type, $after, (bool) $key = false ); 

Parameters (5)

0. $table
The table.
1. $name (string)
The name.
2. $type
The type.
3. $after
The after.
4. $key — Optional. (bool) => false
The key.

Usage

  1. if ( !function_exists( 'M_add_possible_missing_fields' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'membership-2/app_old/membershipincludes/classes/upgrade.php'; 
  3.  
  4. // The table. 
  5. $table = null; 
  6.  
  7. // The name. 
  8. $name = ''; 
  9.  
  10. // The type. 
  11. $type = null; 
  12.  
  13. // The after. 
  14. $after = null; 
  15.  
  16. // The key. 
  17. $key = false; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = M_add_possible_missing_fields($table, $name, $type, $after, $key); 
  21.  

Defined (1)

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

/app_old/membershipincludes/classes/upgrade.php  
  1. function M_add_possible_missing_fields( $table, $name, $type, $after, $key = false ) { 
  2.  
  3. global $wpdb; 
  4.  
  5. switch($name) { 
  6. case 'usinggateway': $defaults = $name . " " . $type . " default 'admin' AFTER " . $after; 
  7. $sql = "ALTER TABLE " . $table . " ADD COLUMN " . $defaults; 
  8. $wpdb->query( $sql ); 
  9. // Add the key 
  10. $sql = "ALTER TABLE " . $table . " ADD INDEX (`" . $name . "`)"; 
  11. $wpdb->query( $sql ); 
  12. break; 
  13.  
  14. default: $defaults = $name . " " . $type . " AFTER " . $after; 
  15. $sql = "ALTER TABLE " . $table . " ADD COLUMN " . $defaults; 
  16. $wpdb->query( $sql ); 
  17. if($key) { 
  18. $sql = "ALTER TABLE " . $table . " ADD INDEX (`" . $name . "`)"; 
  19. $wpdb->query( $sql ); 
  20. break; 
  21.