summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/appframework/db/db.php9
-rw-r--r--lib/private/db/connection.php10
-rw-r--r--lib/public/idbconnection.php9
3 files changed, 28 insertions, 0 deletions
diff --git a/lib/private/appframework/db/db.php b/lib/private/appframework/db/db.php
index 8e3fa6e4197..9f912f9c0a4 100644
--- a/lib/private/appframework/db/db.php
+++ b/lib/private/appframework/db/db.php
@@ -258,4 +258,13 @@ class Db implements IDb {
return $this->connection->tableExists($table);
}
+ /**
+ * Espace a parameter to be used in a LIKE query
+ *
+ * @param string $param
+ * @return string
+ */
+ public function escapeLikeParameter($param) {
+ return $this->connection->escapeLikeParameter($param);
+ }
}
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index 4d33cd968af..1b86d3d383a 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -301,4 +301,14 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
public function inTransaction() {
return $this->getTransactionNestingLevel() > 0;
}
+
+ /**
+ * Espace a parameter to be used in a LIKE query
+ *
+ * @param string $param
+ * @return string
+ */
+ public function escapeLikeParameter($param) {
+ return addcslashes($param, '\\_%');
+ }
}
diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php
index 6a4373583fa..945ca142163 100644
--- a/lib/public/idbconnection.php
+++ b/lib/public/idbconnection.php
@@ -206,4 +206,13 @@ interface IDBConnection {
* @since 8.0.0
*/
public function tableExists($table);
+
+ /**
+ * Escape a parameter to be used in a LIKE query
+ *
+ * @param string $param
+ * @return string
+ * @since 9.0.0
+ */
+ public function escapeLikeParameter($param);
}