summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/postgre/postgre_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers/postgre/postgre_driver.php')
-rw-r--r--system/database/drivers/postgre/postgre_driver.php31
1 files changed, 28 insertions, 3 deletions
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 9d53b1ef8..8d0d8901c 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -34,6 +34,10 @@ class CI_DB_postgre_driver extends CI_DB {
var $_escape_char = '"';
+ // clause and character used for LIKE escape sequences
+ var $_like_escape_str = " ESCAPE '%s' ";
+ var $_like_escape_chr = '!';
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -253,11 +257,32 @@ class CI_DB_postgre_driver extends CI_DB {
*
* @access public
* @param string
+ * @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str)
- {
- return pg_escape_string($str);
+ function escape_str($str, $like = FALSE)
+ {
+ if (is_array($str))
+ {
+ foreach($str as $key => $val)
+ {
+ $str[$key] = $this->escape_str($val, $like);
+ }
+
+ return $str;
+ }
+
+ $str = pg_escape_string($str);
+
+ // escape LIKE condition wildcards
+ if ($like === TRUE)
+ {
+ $str = str_replace( array('%', '_', $this->_like_escape_chr),
+ array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
+ $str);
+ }
+
+ return $str;
}
// --------------------------------------------------------------------