-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPdoMysql.php
63 lines (52 loc) · 1.63 KB
/
PdoMysql.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace ByJG\AnyDataset\Db;
use ByJG\AnyDataset\Db\Exception\DbDriverNotConnected;
use ByJG\Util\Uri;
use PDO;
class PdoMysql extends DbPdoDriver
{
public static function schema(): array
{
return ['mysql', 'mariadb'];
}
protected array $mysqlAttr = [
"ca" => PDO::MYSQL_ATTR_SSL_CA,
"capath" => PDO::MYSQL_ATTR_SSL_CAPATH,
"cert" => PDO::MYSQL_ATTR_SSL_CERT,
"key" => PDO::MYSQL_ATTR_SSL_KEY,
"cipher" => PDO::MYSQL_ATTR_SSL_CIPHER,
"verifyssl" => 1014 // PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT (>=7.1)
];
/**
* PdoMysql constructor.
*
* @param Uri $connUri
* @throws DbDriverNotConnected
*/
public function __construct(Uri $connUri)
{
$preOptions = [];
$postOptions = [
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
];
$executeAfterConnect = [
"SET NAMES utf8"
];
if (!empty($connUri->getQuery())) {
foreach ($this->mysqlAttr as $key => $property) {
$value = $connUri->getQueryPart($key);
if (!empty($value)) {
$prepValue = urldecode($value);
if ($prepValue === 'false') {
$prepValue = false;
} else if ($prepValue === 'true') {
$prepValue = true;
}
$preOptions[$property] = $prepValue;
}
}
}
$this->setSupportMultiRowset(true);
parent::__construct($connUri, $preOptions, $postOptions, $executeAfterConnect);
}
}