diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-05-25 00:01:06 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-05-25 00:01:06 +0200 |
commit | 21cb2d32edd595a38189cdba137e694c3a22e1f0 (patch) | |
tree | d66a2f38e25f7b0a830d1b7d0fe9d842c50608a5 /system/database/drivers/mysql | |
parent | d06acd85cdfff5411474b46afee36fb77baa1200 (diff) |
Fix issue #136 (MySQL escape_like_str())
Diffstat (limited to 'system/database/drivers/mysql')
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 161f99541..d801a9aaf 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -47,7 +47,7 @@ class CI_DB_mysql_driver extends CI_DB { // clause and character used for LIKE escape sequences - not used in MySQL protected $_like_escape_str = ''; - protected $_like_escape_chr = ''; + protected $_like_escape_chr = '\\'; /** * The syntax to count rows is slightly different across different @@ -291,7 +291,9 @@ class CI_DB_mysql_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - return str_replace(array('%', '_'), array('\\%', '\\_'), $str); + return 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; |