Osclass Documentation
Download OslcassCodeIssuesSupport Forum
v3.9.0
v3.9.0
  • Osclass
  • Beginners
    • Install
    • Updating Osclass
    • Osclass Cron
  • Configuring Osclass
    • Mail Server
    • Installing Locations
    • Increase PHP memory limit
    • Improving Search
    • Configure Cache
  • Developers
    • Basic Osclass
      • Contribute to Osclass
      • Coding Style
      • Debug PHP Errors
      • Debug SQL Queries
      • How to write a bug report
      • Database model and diagram
    • Plugins and Themes
      • Auto-update themes and plugins
      • Administrator Menus
      • Admin Toolbar
      • Style and scripts enqueue functions
      • Routes
  • Legacy Installations Pre 3.8.0
    • Introduction
    • Remove calls to Osclass
      • Delete featured products from Admin.
      • Stop auto upgrading.
      • Stop checking for updates from Osclass.
      • Disable Upgrade page
    • Remove Market from admin frontend
      • Delete Market from Admin menu.
      • Delete Market from Plugins.
      • Delete Market from Appearance (themes).
      • Delete Connect Market from Admin toolbar.
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Developers
  2. Basic Osclass

Debug SQL Queries

Note: This will have a performance impact on your site, so make sure to turn this off in your production site.

The OSC_DEBUG_DB constant, added in version 2.3, saves the database queries to an array and at the end of the execution the queries are displayed at the end the page. The information saves each query: the sql string, how long that query took to execute, the sql number error and string if there has been some sql error.

The OSC_DEBUG_DB_LOG constant, added in version 2.3, logs the sql queries to a file called queries.log in oc-content. If you want to debug the sql queries of the AJAX calls or cron, you must use OSC_DEBUG_DB_LOG because we can't print these at the end of the page. If Apache doesn't have write permissions, you may need to create the file first and set the appropriate permissions (i.e. use 666).

The OSC_DEBUG_DB_EXPLAIN constant, added in version 2.3, run an EXPLAIN query for each select query and logs the result to a file called explain_queries.log queries. It should be used only during the development of OSClass, themes or plugins to see the performance of the queries. Remember, if Apache doesn't have write permissions, you may need to create the file first and set the appropriate permissions (i.e. use 666).

/**
 * Copy this code to config.php file
 *
 * This will show SQL queries at the bottom of the site
 */
define('OSC_DEBUG_DB', true) ;
/**
 * Copy this code to config.php file
 *
 * This will log all sql to a file called queries.log in oc-content.
 * 
 * If Apache doesn't have write permissions, you may need to create the file first 
 * and set the appropriate permissions (i.e. use 666).
 */
define('OSC_DEBUG_DB', true) ;
define('OSC_DEBUG_DB_LOG', true) ;
/**
 * Copy this code to config.php file
 *
 * This will run a EXPLAIN sql query for each SELECT sql statement.
 * The results will be logged to a file called explain_queries.log in oc-content.
 * 
 * If Apache doesn't have write permissions, you may need to create the file first 
 * and set the appropriate permissions (i.e. use 666).
 */
define('OSC_DEBUG_DB_EXPLAIN', true) ;
PreviousDebug PHP ErrorsNextHow to write a bug report

Last updated 5 years ago

Was this helpful?