DBI changes

This commit is contained in:
David Anderson 2004-04-02 23:45:26 +00:00
parent 70e3d68643
commit 2a1e246658
2 changed files with 46 additions and 6 deletions

20
plugins/include/dbi.inc Executable file
View File

@ -0,0 +1,20 @@
/* SQL Database API
* By the AMX Mod X Development Team
*/
#if defined _dbi_included
#endinput
#endif
#define _dbi_included
native dbi_connect(host[], user[], pass[], dbname[], error[]="", maxlength=1);
native dbi_query(sql, query[], {Float,_}:...);
native dbi_nextrow(sql);
native dbi_getfield(sql, fieldnum, dest[], maxlen);
native dbi_close(sql);
native dbi_error(sql);

View File

@ -11,22 +11,42 @@
#endif #endif
#define _mysql_included #define _mysql_included
#include <dbi>
/* Opens connection. If already such exists then that will be used. /* Opens connection. If already such exists then that will be used.
* Function returns sql id to use with other sql natives. * Function returns sql id to use with other sql natives.
* Host can be plain ip or with port seperated with ':' char. */ * Host can be plain ip or with port seperated with ':' char. */
native mysql_connect(host[],user[],pass[],dbname[],error[],maxlength); stock mysql_connect(host[],user[],pass[],dbname[],error[],maxlength)
{
dbi_connect(host, user, pass, dbname, error, maxlength)
}
/* Uses an existing connection (sql) to perform a new query (query) (might close previous query if any). */ /* Uses an existing connection (sql) to perform a new query (query) (might close previous query if any). */
native mysql_query(sql,query[], {Float,_}:...); stock mysql_query(sql,query[])
{
dbi_query(sql, query)
}
/* Prepares next row of current query (sql) for read access ; returns the number of the row, 0 at end. */ /* Prepares next row of current query (sql) for read access ; returns the number of the row, 0 at end. */
native mysql_nextrow(sql); stock mysql_nextrow(sql)
{
dbi_nextrow(sql)
}
/* Stores specified column (fieldnum) of current query (sql) in (dest) with (maxlength) characters maximum. */ /* Stores specified column (fieldnum) of current query (sql) in (dest) with (maxlength) characters maximum. */
native mysql_getfield(sql,fieldnum,dest[],maxlength); stock mysql_getfield(sql,fieldnum,dest[],maxlength)
{
dbi_getfield(sql, fieldnum, dest, maxlength)
}
/* Clears query (sql) and closes connection (if any other plugin doesn't use it). */ /* Clears query (sql) and closes connection (if any other plugin doesn't use it). */
native mysql_close(sql); stock mysql_close(sql)
{
dbi_close(sql)
}
/* Stores last error of current query/connection (sql) in (dest) with (maxlength) characters maximum. */ /* Stores last error of current query/connection (sql) in (dest) with (maxlength) characters maximum. */
native mysql_error(sql,dest[],maxlength); stock mysql_error(sql,dest[],maxlength)
{
dbi_error(sql, dest, maxlength)
}