From d3a598f589a44c62817664f20d0d548697e631c5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 21 Jul 2018 09:07:20 -0400 Subject: [PATCH] Update DBA::escape to match dbesc() --- src/Database/DBA.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 8e5a621b36..87b2476d4f 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); } } -- 2.39.5