Skip to content

Commit e70e5ac

Browse files
committed
Merge branch '1.x'
2 parents 0d979ec + 05b2020 commit e70e5ac

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pdo.php
1212
.idea/
1313

1414
/test.php
15+
/mysql80ab-cert.pem

tests/ReflectorFactory.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function create(string $cacheDir): QueryReflector
3939
$user = getenv('DBA_USER') ?: $_ENV['DBA_USER'];
4040
$password = getenv('DBA_PASSWORD') ?: $_ENV['DBA_PASSWORD'];
4141
$dbname = getenv('DBA_DATABASE') ?: $_ENV['DBA_DATABASE'];
42-
$ssl = (bool) (getenv('DBA_SSL') ?: $_ENV['DBA_SSL'] ?? false);
42+
$ssl = (string) (getenv('DBA_SSL') ?: $_ENV['DBA_SSL'] ?? '');
4343
$mode = getenv('DBA_MODE') ?: $_ENV['DBA_MODE'];
4444
$reflector = getenv('DBA_REFLECTOR') ?: $_ENV['DBA_REFLECTOR'];
4545
}
@@ -80,7 +80,12 @@ public static function create(string $cacheDir): QueryReflector
8080
$reflector = new MysqliQueryReflector($mysqli);
8181
$schemaHasher = new SchemaHasherMysql($mysqli);
8282
} elseif ('pdo-mysql' === $reflector) {
83-
$pdo = new PDO(sprintf('mysql:dbname=%s;host=%s', $dbname, $host), $user, $password);
83+
$options = [];
84+
if ($ssl !== '') {
85+
$options[PDO::MYSQL_ATTR_SSL_CA] = $ssl;
86+
$options[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = false;
87+
}
88+
$pdo = new PDO(sprintf('mysql:dbname=%s;host=%s', $dbname, $host), $user, $password, $options);
8489
$reflector = new PdoMysqlQueryReflector($pdo);
8590
$schemaHasher = new SchemaHasherMysql($pdo);
8691
} elseif ('pdo-pgsql' === $reflector) {

0 commit comments

Comments
 (0)