summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-11-05 16:31:56 +0100
committerRobin Appelman <icewind@owncloud.com>2015-11-05 16:41:30 +0100
commitd514200b560c035d71304b54439c4b917de74069 (patch)
tree43551afaea9d7fb7fea738c0bf44aa5d5502fe06
parent556fabf15d2146e7bf8c64b5575305d042e736d7 (diff)
downloadnextcloud-server-d514200b560c035d71304b54439c4b917de74069.tar.gz
nextcloud-server-d514200b560c035d71304b54439c4b917de74069.zip
Add escapeLikeParameter to IDBConnection
-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);
}