summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries/MY_Database.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/libraries/MY_Database.php')
-rw-r--r--modules/gallery/libraries/MY_Database.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php
index 604b6484..33759b67 100644
--- a/modules/gallery/libraries/MY_Database.php
+++ b/modules/gallery/libraries/MY_Database.php
@@ -32,6 +32,9 @@ abstract class Database extends Database_Core {
$config["connection"]["params"] = null;
}
parent::__construct($config);
+ if (gallery::show_profiler()) {
+ $this->config['benchmark'] = true;
+ }
}
/**
@@ -85,4 +88,14 @@ abstract class Database extends Database_Core {
static function set_default_instance($db) {
self::$instances["default"] = $db;
}
+
+ /**
+ * Escape LIKE queries, add wildcards. In MySQL queries using LIKE, _ and % characters are
+ * treated as wildcards similar to ? and *, respectively. Therefore, we need to escape _, %,
+ * and \ (the escape character itself).
+ */
+ static function escape_for_like($value) {
+ // backslash must go first to avoid double-escaping
+ return addcslashes($value, '\_%');
+ }
} \ No newline at end of file