Ale*_*art 7 php t-sql sql-server
我想知道PHP中SQL Server转义字符串的等价物是什么?
有趣的问题,我不知道,但你可以使用PDO::quote()与PDO_DBLIB驱动程序.
编辑:好像这个人 从StackOverflow得到它:
function mssql_escape($data) {
if(is_numeric($data))
return $data;
$unpacked = unpack('H*hex', $data);
return '0x' . $unpacked['hex'];
}
Run Code Online (Sandbox Code Playgroud)
另外一个选项:
function mssql_escape($str)
{
if(get_magic_quotes_gpc())
{
$str= stripslashes($str);
}
return str_replace("'", "''", $str);
}
Run Code Online (Sandbox Code Playgroud)