codeIgniter使用mysql_real_escape_string()而不是数据库连接问题 [英] codeIgniter use mysql_real_escape_string() instead.database connection issue
问题描述
我有代码点火器安装在服务器与数据库我想运行相同的数据库在我的MAC,我使用MAMP和我复制htdocs项目文件夹,但我有这个错误
你会帮助我!
I have code igniter installed on server with database I want to run the same db on my mac, I used MAMP and I copy the project folder inside htdocs, but I have this error would you please help me!
ErrorException [ 8192 ]: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.
推荐答案
不要害怕更改核心文件alter FCPATH / system / database / drivers / mysqli / mysqli_driver.php
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;
}
我有同样的问题
更好的解决方案 - > https:// ellislab .com / forums / viewthread / 228288 / 在github中说明它将在CodeIgniter 3.0中修复该修复程序已经存在于该仓库
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"
这篇关于codeIgniter使用mysql_real_escape_string()而不是数据库连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!