Database Configuration
Pragma CMS uses a multi-tenant architecture. The Platform (Super-Admin) manages its own master database, while each individual site relies on its own dedicated database.
The config_db.php File
To ensure maximum performance and security, database credentials are stored in a site-specific configuration file located at sites/{site_handle}/config_db.php.
This file must return a PHP associative array containing the following keys:
PHP
<?php
// sites/my-site/config_db.php
return [
'host' => '127.0.0.1',
'port' => '3306',
'name' => 'pragma_mysite_db',
'user' => 'db_user',
'password' => 'secure_password'
];
The Connection Lifecycle
Pragma CMS uses a highly secure, static PDO wrapper (Database::class).
When a request targets a specific client site, the index.php router automatically performs a context switch:
- It identifies the target site based on the requested domain.
- It loads the client's
config_db.php. - It forces a reconnection using
Database::reconnect(), instantly isolating the request from the Master Platform database.
Security Constraints Enforced Automatically:
- Prepared Statements Only: The core engine strictly utilizes parameterized queries (
PDO::prepare) to prevent SQL Injection. - Strict UTF-8: The connection is forced into
utf8mb4_unicode_ciat the MySQL server level (PDO::MYSQL_ATTR_INIT_COMMAND), guaranteeing native support for emojis, special characters, and multilingual alphabets. - Exception Mode:
PDO::ERRMODE_EXCEPTIONis globally enabled. Silent database failures are impossible; they are immediately caught and logged.