]> git.mxchange.org Git - friendica.git/commitdiff
Update DBA::escape to match dbesc()
authorHypolite Petovan <mrpetovan@gmail.com>
Sat, 21 Jul 2018 13:07:20 +0000 (09:07 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 23 Jul 2018 19:13:42 +0000 (15:13 -0400)
src/Database/DBA.php

index 8e5a621b3689819f93ec021506716debf7f6561e..87b2476d4fc55e656587562bad2b82c6e1167a26 100644 (file)
@@ -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);
                }
        }