Driver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 3
1
<?php declare(strict_types=1);
2
/**
3
 * Query
4
 *
5
 * SQL Query Builder / Database Abstraction Layer
6
 *
7
 * PHP version 7.1
8
 *
9
 * @package     Query
10
 * @author      Timothy J. Warren <[email protected]>
11
 * @copyright   2012 - 2018 Timothy J. Warren
12
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @link        https://git.timshomepage.net/aviat4ion/Query
14
 */
15
namespace Query\Drivers\Mysql;
16
17
use PDO;
18
use Query\Drivers\AbstractDriver;
19
20
/**
21
 * MySQL specific class
22
 */
23
class Driver extends AbstractDriver {
24
25
	/**
26
	 * Set the backtick as the MySQL escape character
27
	 *
28
	 * @var string
29
	 */
30
	protected $escapeCharOpen = '`';
31
32
	/**
33
	 * Set the backtick as the MySQL escape character
34
	 *
35
	 * @var string
36
	 */
37
	protected $escapeCharClose = '`';
38
39
	/**
40
	 * Connect to MySQL Database
41
	 *
42
	 * @codeCoverageIgnore
43
	 * @param string $dsn
44
	 * @param string $username
45
	 * @param string $password
46
	 * @param array $options
47
	 */
48
	public function __construct(string $dsn, string $username=NULL, string $password=NULL, array $options=[])
49
	{
50
		// Set the charset to UTF-8
51
		if (\defined('\\PDO::MYSQL_ATTR_INIT_COMMAND'))
52
		{
53
			$options = array_merge($options, [
54
				PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF-8 COLLATE 'UTF-8'",
55
			]);
56
		}
57
58
		if (strpos($dsn, 'mysql') === FALSE)
59
		{
60
			$dsn = 'mysql:'.$dsn;
61
		}
62
63
		parent::__construct($dsn, $username, $password, $options);
64
	}
65
}