Trongate PHP Framework Docs
Introduction
Basic Concepts
Understanding Routing
Intercepting Requests
Module Fundamentals
Database Operations
Templates
Helpers
Form Handling
Working With Files
Image Manipulation
Working With Dates & Times
Authorization & Authentication
Tips And Best Practices

Using Debug Mode

The db module ships with a built-in Debug Mode.

Flip one switch → raw SQL dumps straight to your screen. No logs. No var_dump hell. Just the truth.

Enable It. Own It.

  1. Open modules/db/Db.php
  2. Find private $debug = false;
  3. Make it true

Done. Every query now screams at you.

What You’ll See

Run any $this->db method → a big yellow box appears before your normal output, showing the exact SQL before PDO binds the parameters.

Debug mode in action – raw SQL on screen
Zero guesswork. Pure SQL.

Real Example

Let’s say you have this controller method:

Visit the URL → here’s what happens:

Debug OFF

You only see the nicely formatted JSON (thanks to ):

Debug ON

First you get the yellow debug box:

QUERY TO BE EXECUTED:

-> SELECT * FROM users ORDER BY id

PLEASE NOTE: The query shown above is how the query would look before binding.

…then, immediately after, the exact same pretty JSON as before.

doesn’t care that Debug Mode is on - it still outputs the data perfectly.

Pro tip: In API methods, use json($data, true) to dump the JSON and stop the script instantly. Debug Mode will still show the SQL first - perfect for troubleshooting.

Why This Rules

  • See every query before it runs.
  • No log files. No external tools. No nonsense.
  • Works with all db methods.
  • Turn it off in production → one line → gone.

Never ship with $debug = true unless you enjoy giving away your schema for free.