2020-08-04 11:25:22 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
namespace Config;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
use CodeIgniter\Database\Config;
|
|
|
|
|
2020-05-27 18:46:16 +02:00
|
|
|
/**
|
|
|
|
* Database Configuration
|
|
|
|
*/
|
2021-04-02 17:20:02 +00:00
|
|
|
class Database extends Config
|
2020-05-27 18:46:16 +02:00
|
|
|
{
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* The directory that holds the Migrations and Seeds directories.
|
2020-06-10 15:00:12 +00:00
|
|
|
*/
|
2021-05-14 17:59:35 +00:00
|
|
|
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* Lets you choose which connection group to use if no other is specified.
|
2020-06-10 15:00:12 +00:00
|
|
|
*/
|
2021-05-14 17:59:35 +00:00
|
|
|
public string $defaultGroup = 'default';
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
|
|
|
* The default database connection.
|
|
|
|
*
|
2022-03-04 14:33:48 +00:00
|
|
|
* @var array<string, mixed>
|
2020-06-10 15:00:12 +00:00
|
|
|
*/
|
2021-05-14 17:59:35 +00:00
|
|
|
public array $default = [
|
2023-08-27 13:26:06 +00:00
|
|
|
'DSN' => '',
|
|
|
|
'hostname' => 'localhost',
|
|
|
|
'username' => '',
|
|
|
|
'password' => '',
|
|
|
|
'database' => '',
|
|
|
|
'DBDriver' => 'MySQLi',
|
|
|
|
'DBPrefix' => 'cp_',
|
|
|
|
'pConnect' => false,
|
|
|
|
'DBDebug' => true,
|
|
|
|
'charset' => 'utf8mb4',
|
|
|
|
'DBCollat' => 'utf8mb4_unicode_ci',
|
|
|
|
'swapPre' => '',
|
|
|
|
'encrypt' => false,
|
|
|
|
'compress' => false,
|
|
|
|
'strictOn' => false,
|
|
|
|
'failover' => [],
|
|
|
|
'port' => 3306,
|
|
|
|
'numberNative' => false,
|
2024-04-26 09:26:22 +00:00
|
|
|
'dateFormat' => [
|
|
|
|
'date' => 'Y-m-d',
|
|
|
|
'datetime' => 'Y-m-d H:i:s',
|
|
|
|
'time' => 'H:i:s',
|
|
|
|
],
|
2020-06-10 15:00:12 +00:00
|
|
|
];
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* This database connection is used when running PHPUnit database tests.
|
2020-06-10 15:00:12 +00:00
|
|
|
*
|
2022-03-04 14:33:48 +00:00
|
|
|
* @var array<string, mixed>
|
2020-06-10 15:00:12 +00:00
|
|
|
*/
|
2021-05-14 17:59:35 +00:00
|
|
|
public array $tests = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'DSN' => '',
|
2020-06-10 15:00:12 +00:00
|
|
|
'hostname' => '127.0.0.1',
|
|
|
|
'username' => '',
|
|
|
|
'password' => '',
|
|
|
|
'database' => ':memory:',
|
|
|
|
'DBDriver' => 'SQLite3',
|
2021-05-19 16:35:13 +00:00
|
|
|
'DBPrefix' => 'db_',
|
2022-06-13 16:30:34 +00:00
|
|
|
// Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
2023-06-12 14:47:38 +00:00
|
|
|
'pConnect' => false,
|
2023-07-06 15:56:05 +00:00
|
|
|
'DBDebug' => true,
|
2023-06-12 14:47:38 +00:00
|
|
|
'charset' => 'utf8',
|
2024-04-26 09:26:22 +00:00
|
|
|
'DBCollat' => '',
|
2023-06-12 14:47:38 +00:00
|
|
|
'swapPre' => '',
|
|
|
|
'encrypt' => false,
|
|
|
|
'compress' => false,
|
|
|
|
'strictOn' => false,
|
|
|
|
'failover' => [],
|
|
|
|
'port' => 3306,
|
2022-06-13 16:30:34 +00:00
|
|
|
'foreignKeys' => true,
|
2023-07-06 15:56:05 +00:00
|
|
|
'busyTimeout' => 1000,
|
2024-04-26 09:26:22 +00:00
|
|
|
'dateFormat' => [
|
|
|
|
'date' => 'Y-m-d',
|
|
|
|
'datetime' => 'Y-m-d H:i:s',
|
|
|
|
'time' => 'H:i:s',
|
|
|
|
],
|
2020-06-10 15:00:12 +00:00
|
|
|
];
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
//--------------------------------------------------------------------
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
// Ensure that we always set the database group to 'tests' if
|
|
|
|
// we are currently running an automated test suite, so that
|
|
|
|
// we don't overwrite live data on accident.
|
|
|
|
if (ENVIRONMENT === 'testing') {
|
|
|
|
$this->defaultGroup = 'tests';
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
//--------------------------------------------------------------------
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|