Commits

kenjis committed fe88182

fix MySQL $this->db->escape_like_str() wildcard escaping bug

  • Participants
  • Parent commits 0fd34e0

Comments (0)

Files changed (1)

system/database/drivers/mysql/mysql_driver.php

 	   		return $str;
 	   	}
 
+		// escape LIKE condition wildcards
+		if ($like === TRUE)
+		{
+			$str = str_replace(array('\\', '%', '_'), array('\\\\', '\%', '\_'), $str);
+		}
+
 		if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id))
 		{
 			$str = mysql_real_escape_string($str, $this->conn_id);
 			$str = addslashes($str);
 		}
 
-		// escape LIKE condition wildcards
-		if ($like === TRUE)
-		{
-			$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
-		}
-
 		return $str;
 	}