Header Small Ahoy!

Getting Started

Database Compatibility

Trongate's Model class utilizes PDO (PHP Data Objects) for database interaction, a robust library included in most PHP installations. PDO supports a variety of databases:

Trongate has been tested extensively using MySQL and MariaDB. While interaction with other database types (such as those listed above) is technically possible, guidance or examples for other databases (such as PostgreSQL, Oracle, etc.) will not be covered in this chapter.

The Database Configuration File

Trongate establishes database connections using a configuration file named database.php, located in the 'config' directory of your web application.

The configuration settings will vary depending on your setup and chosen database. Below is an example configuration for a database named 'waterways' hosted locally:

<?php
// Database settings
define("HOST", "127.0.0.1");
define("PORT", "3306"); // Default MySQL port
define("USER", "root");
define("PASSWORD", "");
define("DATABASE", "waterways");
When configuring a local database, it's recommended to use '127.0.0.1' instead of 'localhost'. While 'localhost' often works, '127.0.0.1' bypasses certain system steps and has been found to offer greater reliability, especially with third-party database management tools like Navicat or the Trongate Desktop App.

The 'PORT' setting is optional in many cases. If your database server uses the default port (3306 for MySQL), you typically do not need to specify it explicitly in your configuration. However, if your database server runs on a different port or if you encounter connection issues, specifying the correct port number becomes necessary.