codeIgniter use mysql_real_escape_string() instead.database connection issue
Don't be afraid to change core files, just alter FCPATH/system/database/drivers/mysqli/mysqli_driver.php
function escape_str($str, $like = FALSE){ if (is_array($str)) { foreach ($str as $key => $val) { $str[$key] = $this->escape_str($val, $like); } return $str; } if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id)) { $str = mysqli_real_escape_string($this->conn_id, $str); } else { $str = addslashes($str); } // escape LIKE condition wildcards if ($like === TRUE) { $str = str_replace(array('%', '_'), array('\\%', '\\_'), $str); } return $str;}
I had the same issue
Better solution -> https://ellislab.com/forums/viewthread/228288/ "stated in github that it will be fixed in CodeIgniter 3.0 the fix already exists in that repository"
Try this
function escapeString($val) { $db = get_instance()->db->conn_id; $val = mysqli_real_escape_string($db, $val); return $val;}
try this:
$db['development']['hostname'] = 'mysql:host=localhost';$db['development']['dbdriver'] = 'pdo';$db['staging']['hostname'] = 'mysql:host=localhost';$db['staging']['dbdriver'] = 'pdo';
I have update the answer