|
发表于 2007-12-18 15:39:34
|
显示全部楼层
|阅读模式
来自 中国–广东–深圳–福田区
刚才有朋友PM我,说用AMXX的SQL源码,需要这样操作查询:
new qcolAuth = SQL_FieldNameToNum(query, "auth")
new qcolPass = SQL_FieldNameToNum(query, "password")
new qcolAccess = SQL_FieldNameToNum(query, "access")
new qcolFlags = SQL_FieldNameToNum(query, "flags")
while ((g_aNum < MAX_ADMINS) && (SQL_MoreResults(query)))
{
SQL_ReadResult(query, qcolAuth, g_aName[g_aNum], 31)
SQL_ReadResult(query, qcolPass, g_aPassword[g_aNum], 31)
SQL_ReadResult(query, qcolAccess, szAccess, 31)
SQL_ReadResult(query, qcolFlags, szFlags, 31)
g_aAccess[g_aNum] = read_flags(szAccess)
g_aFlags[g_aNum] = read_flags(szFlags)
++g_aNum
SQL_NextRow(query)
}
用得着这样吗?
new qcolAuth = SQL_FieldNameToNum(query, "auth")
无非就是取出查询语句的"auth"列位于查询语句的第几列,如果你的sql query已经是"select auth,password,access,flags,... from table where ..."这种形式,还有使用SQL_FieldNameToNum的必要吗?
while ((g_aNum < MAX_ADMINS) && (SQL_MoreResults(query)))
{
SQL_ReadResult(query, 0, g_aName[g_aNum], 31)
SQL_ReadResult(query, 1, g_aPassword[g_aNum], 31)
SQL_ReadResult(query, 2, szAccess, 31)
SQL_ReadResult(query, 3, szFlags, 31)
...
}
AMXX原码里面提供的不一定就是完美的,老外考虑问题也不见得是没有缺陷的,不要什么都照搬照套,按自己的思路多想想~
:sweat: |
|