Skip to content

Instantly share code, notes, and snippets.

@kamichimo
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamichimo/c67d9ec2e3cd9f80df7d to your computer and use it in GitHub Desktop.
Save kamichimo/c67d9ec2e3cd9f80df7d to your computer and use it in GitHub Desktop.
発行されたSQL文を表示させる
define('SAVEQUERIES', 1);
function koabase_disp_sql() {
global $wpdb;
echo '<table class="wp-list-table widefat fixed posts">';
echo '<thead><th>SQL</th><th>Time</th><th>Caller</th></thead>';
echo '<tbody>';
foreach ($wpdb->queries as $q) {
list ($query, $time, $caller) = $q;
echo sprintf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$query, $time, str_replace(',', "<br>\n", $caller));
}
echo '</tbody>';
echo '</table>';
}
add_action('shutdown', 'koabase_disp_sql');
[wp-config.php]
define ('SAVEQUERIES', true);
[デバッグしたい箇所]
global $wpdb;
var_dump($wpdb->queries);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment