How can I debug my database connection for unit testing?

Put a file named db-error.php into the wp-content directory. Here you can ask the global $wpdb object for more detailed errors:

global $wpdb;
$wpdb->print_error();

This will print out the last error message if the database handler.

Leave a Comment