QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads Retrieve MySQL Queries Programatically in WordPress

Retrieve MySQL Queries Programatically in WordPress

You can retrieve the list of executed MySQL queries programatically in WordPress to analyse or display them.

First you need to place the below code in wp-config.php file so that WordPress allows you to do so.

define('SAVEQUERIES', true);

Now using the below PHP code you can retrieve the list of queries

<?php

global $wpdb;
$queries = $wpdb->queries; //$queries stores all the queries.
Feb 4, 2015Narayan Prusty
WordPress Change Empty Trash IntervalHashing using Web Cryptography API
Comments: 1
  1. Arkaprava Majumder
    8 years ago

    Small trick but very useful.

    ReplyCancel

Leave a Reply Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Narayan Prusty

I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

8 years ago 1 Comment WordPress
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
Related Articles
  • WordPress $notoptions Array
  • Add Select Tag using WordPress Settings API
  • wp_load_alloptions() Function
  • Storing Key Value Pairs in CSV using PHP
  • File Upload using WordPress Settings API
Our Sponsor
My Books

2014 - 2015 © QNimate
All tutorials MIT license