1.为了避免SM读取到数据库更新过程中的数据,造成错误,可使用(我猜的,参考)
nativeintSQL_AddQuery(Transaction txn, constchar[] query, any data=0)
2.多搜索集查询(我猜的,参考)
native bool SQL_FetchMoreResults(Handle query)
In some SQL implementations, multiple result sets can exist on one query. This is possible in MySQL with simple queries when executing a CALL query. If this is the case, all result sets must be processed before another query is made.
3.SQL查询预处理(我猜的,参考)
native void SQL_BindParamInt(Handle statement, int param, int number, bool signed=true)
native void SQL_BindParamFloat(Handle statement, int param, float value)
native void SQL_BindParamString(Handle statement, int param, const char[] value, bool copy)
4.不读取任何文件进行MySql连接(写死在插件中)
native Handle SQL_ConnectEx(Handle driver,
const char[] host,
const char[] user,
const char[] pass,
const char[] database,
char[] error,
int maxlength,
bool persistent=true,
int port=0,
int maxTimeout=0)
5.读取database.cfg以外的配置文件进行MySql连接
native Database SQL_ConnectCustom(Handle keyvalues,
char[] error,
int maxlength,
bool persistent)
6.不安全字符转义(不怕崩查询其实用不到 >3)
native bool SQL_EscapeString(Handle database,
const char[] string,
char[] buffer,
int maxlength,
int &written=0)
7.执行转备好的语句(不是SQL语句而是一个句柄)
native bool SQL_Execute(Handle statement)
8.查询绑定(不是SQL语句而是一个句柄)
native DBStatement SQL_PrepareQuery(Handle database, const char[] query, char[] error, int maxlength)
9.判断查询是否有结果(仅适用SELECT语句)
native bool SQL_HasResultSet(Handle query)
10.结果集字段是否为空值
native bool SQL_IsFieldNull(Handle query, int field)
Ps. int field从0开始
11.获取返回集字段长度
native int SQL_FetchSize(Handle query, int field)
Ps. int field从0开始
12.用名称检索字段索引
native bool SQL_FieldNameToNum(Handle query, const char[] name, int &field)
13.用索引检索字段名称
native void SQL_FieldNumToName(Handle query, int field, char[] name, int maxlength)
14.获取上次查询所影响的行数
native int SQL_GetAffectedRows(Handle hndl)
15.拼接查询
native int SQL_FormatQuery(Handle database, char[] buffer, int maxlength, const char[] format, any ...)
Ps. 整挺好,字符串拼接都省了 XDD
16.获取字段个数
native int SQL_GetFieldCount(Handle query)
17.获取驱动句柄
native DBDriver SQL_GetDriver(const char[] name="")
Ps. 留空获取默认驱动
18.获取驱动标识
native void SQL_GetDriverIdent(Handle driver, char[] ident, int maxlength)
19.获取驱动产品
native void SQL_GetDriverProduct(Handle driver, char[] product, int maxlength)
20.获取最后查询错误
native bool SQL_GetError(Handle hndl, char[] error, int maxlength)
更多详细说明请见:https://sourcemod.dev/#/dbi