I have been studying DBAPI and would like to propose an enhancment of the current "escape" with a few of my functions as follow:
The reason for this changes are for magic quote, php version 4.2 and the use of mysql_real_escape.
Please take a look and let me know what you think. Thanks
---->In dbapi.mysql.class.inc.php on line 78
function escape($s){
return mysql_escape_string($s);
}
---->replace with these:lines:
function escape($s){
return $this->mc_escape_string ($s);
}
function mc_escape_string ($istring) {
if ((version_compare(substr(phpversion(),1,3),"4.2")=="-1") && (function_exists(’mysql_real_escape_string’))) {
$istring=$this->mc_quote_smart($istring);
}
else { if (function_exists(’mysql_escape_string’)) { $istring=mysql_escape_string($istring); } } // php 4.2
return($s);
}
function mc_quote_smart($istring) {
if (get_magic_quotes_gpc()) { $istring = stripslashes($istring); }
if (!is_numeric($istring)) { $istring = mysql_real_escape_string($istring); }
return($s);
}
Looks good to me. I’m all for anything that makes it easier to deal with magic quotes.
Thanks for the feedback! Is this worthy of include it in the next release?
Thanks