gde_debug_tables

Check health of database tables.

Description

gde_debug_tables( (array) $table = array(), (bool) $verbose = false ); 

Parameters (2)

0. $table — Optional. (array) => array()
The table.
1. $verbose — Optional. (bool) => false
The verbose.

Usage

  1. if ( !function_exists( 'gde_debug_tables' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/functions.php'; 
  3.  
  4. // The table. 
  5. $table = array(); 
  6.  
  7. // The verbose. 
  8. $verbose = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = gde_debug_tables($table, $verbose); 
  12.  

Defined (1)

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

/functions.php  
  1. function gde_debug_tables( $table = array('gde_profiles', 'gde_secure'), $verbose = false ) { 
  2. global $wpdb; 
  3.  
  4. if ( is_array( $table ) ) { 
  5. $ok = true; 
  6. foreach ( $table as $t ) { 
  7. $t = $wpdb->prefix . $t; 
  8. if ( $wpdb->get_var( "SHOW TABLES LIKE '$t'" ) == $t ) { 
  9. // table good 
  10. } else { 
  11. $ok = false; 
  12. gde_dx_log($t . " table missing"); 
  13. break; 
  14. } else { 
  15. $ok = true; 
  16. $table = $wpdb->prefix . $table; 
  17. if ( $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) == $table ) { 
  18. $s = "OK "; 
  19. $c = $wpdb->get_var( "SELECT COUNT(*) FROM $table WHERE 1=1" ); 
  20. $s = $s . "($c items)"; 
  21. } else { 
  22. $s = "NOT OK ($table missing)"; 
  23. $ok = false; 
  24.  
  25. if ( ! $verbose ) { 
  26. return $ok; 
  27. } else { 
  28. return $s;