問題描述
我在帶有數據庫的服務器上安裝了代碼點火器我想在我的 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.
推薦答案
不要害怕改變核心文件,只需改變 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() 代替.database 連接問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!