summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2011-09-14 18:25:14 +0200
committerTimothy Warren <tim@timshomepage.net>2011-09-14 18:25:14 +0200
commitc7ba6640fcd1acfd5865efb5780607c90efc0e24 (patch)
treed4d71875d1452627748b655b40608fac9c2d3d88
parenta6c65337005ac9f8ca8882cdc25341ee45c852df (diff)
Fixed LIKE statement escaping issues
-rw-r--r--system/database/drivers/pdo/pdo_driver.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 5299f1a13..b0bd7075f 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -34,10 +34,9 @@ class CI_DB_pdo_driver extends CI_DB {
// the character used to excape - not necessary for PDO
var $_escape_char = '';
-
- // clause and character used for LIKE escape sequences
- var $_like_escape_str = " {escape '%s'} ";
- var $_like_escape_chr = '!';
+ var $_like_escape_str;
+ var $_like_escape_chr;
+
/**
* The syntax to count rows is slightly different across different
@@ -52,6 +51,23 @@ class CI_DB_pdo_driver extends CI_DB {
{
parent::CI_DB($params);
+ // clause and character used for LIKE escape sequences
+ if(strpos($this->hostname, 'mysql') !== FALSE)
+ {
+ $this->_like_escape_str = '';
+ $this->_like_escape_chr = '';
+ }
+ else if(strpos($this->hostname, 'odbc') !== FALSE)
+ {
+ $this->_like_escape_str = " {escape '%s'} ";
+ $this->_like_escape_chr = '!';
+ }
+ else
+ {
+ $this->_like_escape_str = " ESCAPE '%s' ";
+ $this->_like_escape_chr = '!';
+ }
+
$this->hostname = $this->hostname . ";dbname=".$this->database;
$this->trans_enabled = FALSE;
@@ -306,9 +322,9 @@ class CI_DB_pdo_driver extends CI_DB {
*/
function affected_rows()
{
- if ($this->db->db_debug)
+ if ($this->db_debug)
{
- return $this->db->display_error('db_unsuported_feature');
+ return $this->display_error('db_unsuported_feature');
}
return FALSE;
}