gde_debug_tables
Check health of database tables.
Description
Parameters (2)
- 0. $table — Optional. (array) =>
array()
- The table.
- 1. $verbose — Optional. (bool) =>
false
- The verbose.
Usage
if ( !function_exists( 'gde_debug_tables' ) ) { require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/functions.php'; } // The table. $table = array(); // The verbose. $verbose = false; // NOTICE! Understand what this does before running. $result = gde_debug_tables($table, $verbose);
Defined (1)
The function is defined in the following location(s).
- /functions.php
- function gde_debug_tables( $table = array('gde_profiles', 'gde_secure'), $verbose = false ) {
- global $wpdb;
- if ( is_array( $table ) ) {
- $ok = true;
- foreach ( $table as $t ) {
- $t = $wpdb->prefix . $t;
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$t'" ) == $t ) {
- // table good
- } else {
- $ok = false;
- gde_dx_log($t . " table missing");
- break;
- }
- }
- } else {
- $ok = true;
- $table = $wpdb->prefix . $table;
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) == $table ) {
- $s = "OK ";
- $c = $wpdb->get_var( "SELECT COUNT(*) FROM $table WHERE 1=1" );
- $s = $s . "($c items)";
- } else {
- $s = "NOT OK ($table missing)";
- $ok = false;
- }
- }
- if ( ! $verbose ) {
- return $ok;
- } else {
- return $s;
- }
- }