Inspecting MySQL SELECT Queries in Admin Lists
SQL Query Debugging Guide

The READ List SELECT query is sent by your table main class, in admin/class/crud/YourTable.php.


Revealing the SELECT query

The SQL query sent to your server to get the matching records depends on several parameters:

  • User's rights on the active table
  • Active filters
  • Relations (including user's rights on the related table(s)
  • Sorting
  • Pagination

PHPCG analyses these parameters and builds the query for you.


To display the SQL query on your page (for debugging purpose):

  1. Open the conf/conf.php file and set the DEBUG_DB_QUERIES constant to true.
    You can also enable it from the Generator: Configuration → Settings → check Simulate and debug.
  2. Reload your READ list: all the SQL queries sent to your server are displayed in the debug block of the list page.
  3. Don't forget to set DEBUG_DB_QUERIES back to false when you're done.

PHP CRUD tutorial main page