M_repair_tables

The Membership 2 M repair tables function.

Description

M_repair_tables(); 

Usage

  1. if ( !function_exists( 'M_repair_tables' ) ) { 
  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_repair_tables(); 
  7.  

Defined (1)

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

/app_old/membershipincludes/classes/upgrade.php  
  1. function M_repair_tables() { 
  2.  
  3. global $wpdb; 
  4.  
  5.  
  6. foreach( $tables as $name => $fields ) { 
  7.  
  8. echo "<p>" . __('Checking table : ', 'membership') . $name . " - "; 
  9.  
  10. $sql = "SHOW TABLES LIKE '{$name}';"; 
  11. $t = $wpdb->get_var( $sql ); 
  12.  
  13. if($t == $name) { 
  14. echo "<span style='color: green;'>" . __('Ok', 'membership') . "</span>"; 
  15. echo "</p>"; 
  16.  
  17. echo "<p>" . __('Checking fields in table : ', 'membership') . $name . " - "; 
  18.  
  19. $sql = "SHOW COLUMNS FROM {$name};"; 
  20. $t = $wpdb->get_results( $sql ); 
  21.  
  22. $pfield = ''; 
  23. foreach( $fields as $fieldname => $type ) { 
  24. $found = false; 
  25. echo "<br/>" . $fieldname . " - "; 
  26. foreach($t as $dbf) { 
  27. //print_r($dbf); 
  28. if($dbf->Field == $fieldname && $dbf->Type == $type) { 
  29. $found = true; 
  30. break; 
  31. if($found) { 
  32. echo "<span style='color: green;'>" . __('Ok', 'membership') . "</span>"; 
  33. } else { 
  34.  
  35. M_add_possible_missing_fields( $name, $fieldname, $type, $pfield ); 
  36.  
  37. echo "<span style='color: red;'>" . __('Fixed', 'membership') . "</span>"; 
  38. $pfield = $fieldname; 
  39.  
  40. echo "</p>"; 
  41.  
  42. } else { 
  43.  
  44.  
  45. echo "<span style='color: red;'>" . __('Fixed', 'membership') . "</span>"; 
  46. echo "</p>"; 
  47.  
  48.