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(