外观
For learning purpose, it's meaningful to looking at sql sentences queried by Wordpress. But how to do this? Here is the answer. First, edit the wp-config.php file, just add one line of code as below:
define('SAVEQUERIES', true);Then, find the common footer.php file of your Wordpress theme, add the following code before the ending </body> html tag (attention: here we only allow administrator to see these sql sentences, taking security into consideration):
<?php
if (current_user_can('administrator')){
global $wpdb;
echo "<pre>";
print_r($wpdb->queries);
echo "</pre>";
}
?>That's all you need to do. You can now open a webpage and see corresponding sql sentences at the footer of the page. Thanks for reading!