• johnfrombuc

    (@johnfrombuc)


    Today I installed the debug bar on my dev system @ localhost
    I included the lines

    define(‘WP_DEBUG’, true);
    define(‘SAVEQUERIES’, true);

    into my plugin. And I got some queries in the debug window. However I got only the queries sent by WordPress. My plugin generates its own queries which refer to a separate database (not to the WordPress database). In fact I am interested only in my own queries – not in the queries generated by wordpress . However I don’t get my own queries at all.
    Any idea what could be the problem?

    https://www.ads-software.com/extend/plugins/debug-bar/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I would sure like to know the answer to this question as well. I’m not interested in debugging WordPress, only my own plugins.

    You must define WP_DEBUG in wp-config.php. By the time your plugin is loaded, default constants have been set. Technically speaking, you could write a function to configure the error reporting features as WP_DEBUG does when true.

    I believe SAVEQUERIES can be defined at any point but you will only gather query information from that point in execution and forward.

    In both cases, setting the values in wp-config.php is the best way to gather the most information.

    To the main question: The $wpdb class is responsible for parsing and gathering query information. This functionality is built into WordPress. This plugin does some processing and display, but little else.

    Your simplest option would be to use the WPDB class to connect to your second database and gather the necessary stats. You would also need to copy and modify the DB panel to reference your new global.

    If in fact you are using separate tables within the same database as WP, your path is even easier: use the $wpdb global in your plugin, and your queries will be included in the reporting.

    Doing this is in your interest since WP is in the process of updating WPDB to use improved mysql database modules since PHP will be removing the mysql_* function calls in an upcoming version.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Non-WordPress Queries in Debug Bar’ is closed to new replies.