|
发表于 2008-12-17 21:09:07
|
显示全部楼层
来自 中国–广东–惠州–惠城区
回复: 求教SQL
[php]
#include <amxmodx>
#include <amxmisc>
#include <dbi>
#define PLUGIN "testsql"
#define VERSION "1.0"
#define AUTHOR "1"
new host[33]
new user[33]
new pass[33]
new tabname[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar ("dbi_host", "127.0.0.1")
register_cvar ("dbi_user", "admin")
register_cvar ("dbi_pass", "admin")
register_cvar ("dbi_tabname", "cs")
get_cvar_string("dbi_host",host,32)
get_cvar_string("dbi_user",user,32)
get_cvar_string("dbi_pass",pass,32)
get_cvar_string("dbi_tabname",tabname,32)
set_task(5.0,"name")
}
public name () {
new Sql:dbc
new Result:result
new auth[33]
dbc = dbi_connect(host,user,pass,tabname)
if(dbc==SQL_OK)
{
result = dbi_query (dbc, "SELECT * FROM admins");
if(result>RESULT_NONE)
{
do{
dbi_field(result,1,auth,32);
log_amx ("ID %s",auth);
}while(dbi_nextrow(result));
dbi_free_result(result);
dbi_close(dbc);
}
}
}[/php] |
|