数据库异常– yii \ db \ Exception
Error Info: Array
(
[0] => HY000
[1] => 102
[2] => Incorrect syntax near 'PK'. [102] (severity 15) [INSERT INTO [ORDERS] ([ID], [STATUS], [ZIPFILE], [COLOR], [PRICE]) VALUES (87, 1,'PK]
[3] => -1
[4] => 15
)
↵ 由:PDOException SQLSTATE [HY000]:常规错误:“ PK”附近的语法不正确。102 [102](严重性15)[插入到[订单]([ID],[状态],[压缩文件],[颜色],[价格])值(87、1,'PK)
在yii2应用程序中,我试图使用file_get_uploads php函数上载zip文件,以首先将zip转换为二进制文件并将其保存到SQL Server数据库的'ZIPFILE'列中,但收到上述错误。
Looks like the special characters after PK is truncating the value of ZIPFILE and anything that comes after it in the SQL insert string. If I were to escape the special characters by using the PHP addslashes()
function, I am able to complete the insert, but the zip file gets corrupted because of the additional slashes. Changing encoding is not an option as I use another app to download the data from the database and that app requires the values to be in this encoding.
有没有一种方法可以逃脱特殊字符而不损坏zip文件?