Luminova Framework

Base Database

Last updated: 2024-07-25 19:01:46

Automatic Backup Database Connectivity to ensure your application is always online when needed.

BaseDatabase enables you to specify backup database servers. If the main database specified in the environment file fails to connect, the framework automatically attempts to connect to your backup servers if defined to ensure your application is always ready when users request for it.

  • Class namespace: \Luminova\Base\BaseDatabase
  • This class is an Abstract class

Properties

Optional servers to connect to when main server fails, an associative array with each database configuration keys and values.

protected static array<int,mixed> $databaseBackups = [];

Here is an example on how you can extend and use the base server.

<?php 
namespace App\Config;

use \Luminova\Base\BaseDatabase;

class Servers extends BaseDatabase
{
     protected $databaseBackups = [
          [
               'port' => 0,
               'host' => 'my-db-host',
               'pdo_engine' => 'mysql',
               'connection' => 'pdo',
               'charset' => 'utf8',
               'persistent' => true,
               'emulate_preparse' => false,
               'sqlite_path' => '', // if sqlite
               'username' => 'root',
               'password' => '',
               'database' => 'db_name',
               'socket' => false,
               'socket_path' => ''
          ],
          //...
     ];
}
On this page