1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-05 07:37:25 +02:00

Throw error if 'libmysqlclient' driver is used instead of 'mysqlnd'

This commit is contained in:
Marco
2017-03-18 22:21:23 +01:00
parent 59505479a5
commit 04a2e8ef4e

View File

@@ -66,6 +66,16 @@ abstract class UserManager {
throw new \InvalidArgumentException('The database connection must be an instance of either `PdoDatabase`, `PdoDsn` or `PDO`');
}
$this->db->addOnConnectListener(function (PdoDatabase $db) {
// if a MySQL database is used
if ($db->getDriverName() === 'MySQL') {
// if the required MySQL Native Driver (mysqlnd) is not used (but instead the older MySQL Client Library (libmysqlclient))
if (\extension_loaded('mysqlnd') === false && \stripos($db->getClientVersion(), 'mysqlnd') === false) {
throw new WrongMysqlDatabaseDriverError('You must use PDO with the newer \'mysqlnd\' driver instead of the older \'libmysqlclient\' driver');
}
}
});
}
/**