Browse Source

Add escapeLikeParameter to IDBConnection

tags/v9.0beta1
Robin Appelman 8 years ago
parent
commit
d514200b56
3 changed files with 28 additions and 0 deletions
  1. 9
    0
      lib/private/appframework/db/db.php
  2. 10
    0
      lib/private/db/connection.php
  3. 9
    0
      lib/public/idbconnection.php

+ 9
- 0
lib/private/appframework/db/db.php View File

@@ -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);
}
}

+ 10
- 0
lib/private/db/connection.php View File

@@ -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, '\\_%');
}
}

+ 9
- 0
lib/public/idbconnection.php View File

@@ -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);
}

Loading…
Cancel
Save