函数参考


_SQLite_Escape

Escapes a string or number for use as TEXT in SQLite statements

#include <SQLite.au3>
_SQLite_Escape ( $sString )

参数

$sString 将要换码的字符串

返回值

成功: 返回字符串换码
失败: 返回空字符串,设置 @error
@error: 1 - 错误调用 SQLite API 'sqlite3_mprintf'
2 - 字符串转换为 UTF - 8 错误
3 - 读换码字符串错误

注意/说明

已换码字符串用单引号包围.
例如 "It's a fine day" 换码后为 "It''s a fine day"
二进制数据使用 _SQLite_Encode()
For numeric value to be stored as such, use simple concatenation

相关

_SQLite_Encode

示例/演示


#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
Local $sTestString, $i, $aRow
For $i = 1 To 255
    $sTestString &= Chr($i)
Next
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE test (a)")
_SQLite_Exec(-1, "INSERT INTO test VALUES (" & _SQLite_Escape($sTestString) & ")")
_SQLite_QuerySingleRow(-1, "SELECT a FROM test LIMIT 1", $aRow)
If $aRow[0] = $sTestString Then ConsoleWrite("! identical !" & @CRLF)
_SQLite_Shutdown()