Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
MySQLAccess | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
connect | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | /** |
4 | * @package ClientDLDB |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsdldb; |
9 | |
10 | /** |
11 | * |
12 | */ |
13 | class MySQLAccess extends PDOAccess |
14 | { |
15 | protected $engine = 'MySQL'; |
16 | |
17 | const DEFAULT_DATABASE_NAME = 'dldb_frontend_dev'; |
18 | const DEFAULT_DATABASE_HOST = 'mariadb'; |
19 | const DEFAULT_DATABASE_PORT = 3306; |
20 | const DEFAULT_DATABASE_USER = 'root'; |
21 | const DEFAULT_DATABASE_PASSWORD = 'password'; |
22 | |
23 | protected function connect(array $options) |
24 | { |
25 | $host = $options['host'] ?? static::DEFAULT_DATABASE_HOST; |
26 | $dbname = $options['database'] ?? static::DEFAULT_DATABASE_NAME; |
27 | $user = $options['user'] ?? static::DEFAULT_DATABASE_USER; |
28 | $pass = $options['password'] ?? static::DEFAULT_DATABASE_PASSWORD; |
29 | $port = $options['port'] ?? static::DEFAULT_DATABASE_PORT; |
30 | if (!$host) { |
31 | $host = 'localhost'; |
32 | } |
33 | |
34 | $dsn = 'mysql:host=' . $host . ';port=' . $port . ';dbname=' . $dbname; |
35 | |
36 | try { |
37 | $this->pdo = new \PDO($dsn, $user, $pass); |
38 | } catch (\Exception $e) { |
39 | throw $e; |
40 | } |
41 | } |
42 | } |