Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Database
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Config;
4
5use CodeIgniter\Database\Config;
6
7/**
8 * Database Configuration
9 */
10class Database extends Config
11{
12    /**
13     * The directory that holds the Migrations and Seeds directories.
14     */
15    public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
16
17    /**
18     * Lets you choose which connection group to use if no other is specified.
19     */
20    public string $defaultGroup = 'default';
21
22    /**
23     * The default database connection.
24     *
25     * @var array<string, mixed>
26     */
27    public array $default = [
28        'DSN'          => '',
29        'hostname'     => 'localhost',
30        'username'     => '',
31        'password'     => '',
32        'database'     => '',
33        'DBDriver'     => 'MySQLi',
34        'DBPrefix'     => '',
35        'pConnect'     => false,
36        'DBDebug'      => true,
37        'charset'      => 'utf8mb4',
38        'DBCollat'     => 'utf8mb4_general_ci',
39        'swapPre'      => '',
40        'encrypt'      => false,
41        'compress'     => false,
42        'strictOn'     => false,
43        'failover'     => [],
44        'port'         => 3306,
45        'numberNative' => false,
46        'foundRows'    => false,
47        'dateFormat'   => [
48            'date'     => 'Y-m-d',
49            'datetime' => 'Y-m-d H:i:s',
50            'time'     => 'H:i:s',
51        ],
52    ];
53
54    //    /**
55    //     * Sample database connection for SQLite3.
56    //     *
57    //     * @var array<string, mixed>
58    //     */
59    //    public array $default = [
60    //        'database'    => 'database.db',
61    //        'DBDriver'    => 'SQLite3',
62    //        'DBPrefix'    => '',
63    //        'DBDebug'     => true,
64    //        'swapPre'     => '',
65    //        'failover'    => [],
66    //        'foreignKeys' => true,
67    //        'busyTimeout' => 1000,
68    //        'synchronous' => null,
69    //        'dateFormat'  => [
70    //            'date'     => 'Y-m-d',
71    //            'datetime' => 'Y-m-d H:i:s',
72    //            'time'     => 'H:i:s',
73    //        ],
74    //    ];
75
76    //    /**
77    //     * Sample database connection for Postgre.
78    //     *
79    //     * @var array<string, mixed>
80    //     */
81    //    public array $default = [
82    //        'DSN'        => '',
83    //        'hostname'   => 'localhost',
84    //        'username'   => 'root',
85    //        'password'   => 'root',
86    //        'database'   => 'ci4',
87    //        'schema'     => 'public',
88    //        'DBDriver'   => 'Postgre',
89    //        'DBPrefix'   => '',
90    //        'pConnect'   => false,
91    //        'DBDebug'    => true,
92    //        'charset'    => 'utf8',
93    //        'swapPre'    => '',
94    //        'failover'   => [],
95    //        'port'       => 5432,
96    //        'dateFormat' => [
97    //            'date'     => 'Y-m-d',
98    //            'datetime' => 'Y-m-d H:i:s',
99    //            'time'     => 'H:i:s',
100    //        ],
101    //    ];
102
103    //    /**
104    //     * Sample database connection for SQLSRV.
105    //     *
106    //     * @var array<string, mixed>
107    //     */
108    //    public array $default = [
109    //        'DSN'        => '',
110    //        'hostname'   => 'localhost',
111    //        'username'   => 'root',
112    //        'password'   => 'root',
113    //        'database'   => 'ci4',
114    //        'schema'     => 'dbo',
115    //        'DBDriver'   => 'SQLSRV',
116    //        'DBPrefix'   => '',
117    //        'pConnect'   => false,
118    //        'DBDebug'    => true,
119    //        'charset'    => 'utf8',
120    //        'swapPre'    => '',
121    //        'encrypt'    => false,
122    //        'failover'   => [],
123    //        'port'       => 1433,
124    //        'dateFormat' => [
125    //            'date'     => 'Y-m-d',
126    //            'datetime' => 'Y-m-d H:i:s',
127    //            'time'     => 'H:i:s',
128    //        ],
129    //    ];
130
131    //    /**
132    //     * Sample database connection for OCI8.
133    //     *
134    //     * You may need the following environment variables:
135    //     *   NLS_LANG                = 'AMERICAN_AMERICA.UTF8'
136    //     *   NLS_DATE_FORMAT         = 'YYYY-MM-DD HH24:MI:SS'
137    //     *   NLS_TIMESTAMP_FORMAT    = 'YYYY-MM-DD HH24:MI:SS'
138    //     *   NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
139    //     *
140    //     * @var array<string, mixed>
141    //     */
142    //    public array $default = [
143    //        'DSN'        => 'localhost:1521/XEPDB1',
144    //        'username'   => 'root',
145    //        'password'   => 'root',
146    //        'DBDriver'   => 'OCI8',
147    //        'DBPrefix'   => '',
148    //        'pConnect'   => false,
149    //        'DBDebug'    => true,
150    //        'charset'    => 'AL32UTF8',
151    //        'swapPre'    => '',
152    //        'failover'   => [],
153    //        'dateFormat' => [
154    //            'date'     => 'Y-m-d',
155    //            'datetime' => 'Y-m-d H:i:s',
156    //            'time'     => 'H:i:s',
157    //        ],
158    //    ];
159
160    /**
161     * This database connection is used when running PHPUnit database tests.
162     *
163     * @var array<string, mixed>
164     */
165    public array $tests = [
166        'DSN'         => '',
167        'hostname'    => '127.0.0.1',
168        'username'    => 'root',
169        'password'    => '',
170        'database'    => 'academia_test',
171        'DBDriver'    => 'MySQLi',
172        'DBPrefix'    => '',
173        'pConnect'    => false,
174        'DBDebug'     => true,
175        'charset'     => 'utf8mb4',
176        'DBCollat'    => 'utf8mb4_unicode_ci',
177        'swapPre'     => '',
178        'encrypt'     => false,
179        'compress'    => false,
180        'strictOn'    => false,
181        'failover'    => [],
182        'port'        => 3306,
183        'dateFormat'  => [
184            'date'     => 'Y-m-d',
185            'datetime' => 'Y-m-d H:i:s',
186            'time'     => 'H:i:s',
187        ],
188    ];
189
190    public function __construct()
191    {
192        parent::__construct();
193
194        // Ensure that we always set the database group to 'tests' if
195        // we are currently running an automated test suite, so that
196        // we don't overwrite live data on accident.
197        if (ENVIRONMENT === 'testing') {
198            $this->defaultGroup = 'tests';
199        }
200    }
201}