Last active
August 29, 2015 14:07
-
-
Save kamichimo/c67d9ec2e3cd9f80df7d to your computer and use it in GitHub Desktop.
発行されたSQL文を表示させる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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