If you’ve found an error, spotted something missing, or feel a section could be clearer or better explained, we’d love to hear from you. Your feedback helps keep the documentation accurate and useful for everyone.
Please report issues or suggest improvements on GitHub. Community input is invaluable in making the docs stronger.
Not comfortable with GitHub? No problem — you can also get in touch with us directly via our contact form. We welcome all feedback.
Using Debug Mode
The Trongate Model class includes a 'Debug Mode' feature that allows developers to inspect the raw SQL queries generated by their application. By default, Debug Mode is disabled. To enable it, follow these steps:
- Open the Model.php file located in the application's engine directory.
- Navigate to the top of the file where a private variable named
$debug
can be found. - Change the value of
$debug
fromfalse
totrue
.
For example:
With Debug Mode enabled, PDO will display the SQL queries that will be executed by the application.
Debug Mode Screenshot

Testing Debug Mode
This section demonstrates a practical example of Debug Mode in the Trongate Model class. A test database table named students
will be created, and its records will be retrieved using the Model class. The goal is to fetch some database records and then inspect the raw SQL query by having debug mode set to true.
Step 1: Create a Test Database Table
Before testing Debug Mode, a test table must be created in the database. The table, named students
, will contain the following columns:
- first_name (varchar)
- last_name (varchar)
- email_address (varchar)
The following SQL statement can be used to create the table and insert sample data:
Executing this SQL statement in the database will create the table and insert five test records.
Step 2: Fetching Data from the students
Table
Once the students
table is set up, a method can be created in the Controller to fetch all records using the Model class.
In object-oriented programming, a method is a function that belongs to a class.
The following method retrieves all records from the students
table:
In a Trongate application, methods such as test()
should be placed inside the main controller file of a module. The Trongate framework follows a modular architecture, where each module is a self-contained directory housing its own controllers, views and other assets.
To invoke the test()
method via a URL, the request must adhere to Trongate's routing convention. This means the base URL should be followed by a first URL segment corresponding to the directory name of the module, and a second URL segment specifying the method to be executed.
For example, if the base URL of your application is https://example.com/
and the test()
method resides in the controller of a module named welcome
, the correct URL to invoke the method would be:
This URL structure ensures that Trongate correctly maps the request to the appropriate module and method, facilitating clean and organised application logic.
This test()
method invokes get() - which is part of the Model class - to fetch all records from the students
table, ordered by id
. The method then invokes json() to output the fetched rows in JSON format.
Step 3: Enable Debug Mode
To inspect the raw SQL query being executed, Debug Mode must be enabled. This is done by modifying the Model.php
file and setting $debug = true;
as shown below:
Step 4: Running the Test with Debug Mode Enabled
Once Debug Mode is enabled, the test()
method should be executed by visiting the corresponding URL in a web browser. With Debug Mode active, the raw SQL query will be displayed at the top of the page, followed by the JSON output of the retrieved records.
For example, the displayed SQL query may resemble the following:
The JSON-encoded result set will be displayed below:
The raw SQL query is now visible, providing insights into the underlying database operations.
Step 5: Additional Methods in the Model Class
Debug Mode helps verify that queries are executed as expected. In this example, the get() method from the Model class was used to fetch database records.
The Trongate Model class includes several additional methods for database interaction. These methods will be covered in the next section.