diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 8e5a621b3..87b2476d4 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -251,11 +251,15 @@ class DBA } public static function escape($str) { - switch (self::$driver) { - case 'pdo': - return substr(@self::$connection->quote($str, PDO::PARAM_STR), 1, -1); - case 'mysqli': - return @self::$connection->real_escape_string($str); + if (self::$connected) { + switch (self::$driver) { + case 'pdo': + return substr(@self::$connection->quote($str, PDO::PARAM_STR), 1, -1); + case 'mysqli': + return @self::$connection->real_escape_string($str); + } + } else { + return str_replace("'", "\\'", $str); } }