summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-01-10 15:23:48 +0100
committerAndrey Andreev <narf@bofh.bg>2013-01-10 15:23:48 +0100
commit7545ffd90647cd65aeaff2a21032a13140700c63 (patch)
tree3d1038a6d51d3ecf5ff5380e47fa991c6e3e67c7
parent55899a0ed6a2f5be1c9d800c39051c8c0ce8fcab (diff)
Fix SQLSRV escape_str()
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php24
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 24 insertions, 1 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 0e04c5c67..a6f2d5537 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -230,8 +230,30 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
public function escape_str($str, $like = FALSE)
{
+ if (is_array($str))
+ {
+ foreach ($str as $key => $val)
+ {
+ $str[$key] = $this->escape_str($val, $like);
+ }
+
+ return $str;
+ }
+
// Escape single quotes
- return str_replace("'", "''", $str);
+ $str = str_replace("'", "''", remove_invisible_characters($str));
+
+ // escape LIKE condition wildcards
+ if ($like === TRUE)
+ {
+ 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;
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 744150bb4..2966f659f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -468,6 +468,7 @@ Bug fixes for 3.0
- Fixed a bug (#188) - :doc:`Unit Testing Library <libraries/unit_testing>` filled up logs with error messages for non-existing language keys.
- Fixed a bug (#113) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly handle empty fields that were specified as an array.
- Fixed a bug (#2061) - :doc:`Routing Class <general/routing>` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE.
+- Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values.
Version 2.1.3
=============