From 61f4f2315a7f227c4eb5c2e116da7394a6f04cbc Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Sat, 2 Jun 2018 22:26:25 +0200 Subject: [PATCH] * [ADD] Unit testing. Work in progress. * [MOD] Added some connection options to MySQL handler --- lib/SP/Storage/MySQLHandler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/SP/Storage/MySQLHandler.php b/lib/SP/Storage/MySQLHandler.php index cd30e561..7eff509f 100644 --- a/lib/SP/Storage/MySQLHandler.php +++ b/lib/SP/Storage/MySQLHandler.php @@ -39,7 +39,7 @@ class MySQLHandler implements DBStorageInterface const STATUS_OK = 0; const STATUS_KO = 1; const PDO_OPTS = [ - PDO::ATTR_EMULATE_PREPARES => true, + PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_FOUND_ROWS => true ]; @@ -107,6 +107,10 @@ class MySQLHandler implements DBStorageInterface self::PDO_OPTS ); + // Set prepared statement emulation depending on server version + $serverVersion = $this->db->getAttribute(PDO::ATTR_SERVER_VERSION); + $this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, version_compare($serverVersion, '5.1.17', '<')); + $this->dbStatus = self::STATUS_OK; } catch (\Exception $e) { throw new SPException(