amxmodx/plugins/include/dbi.inc

60 lines
1.9 KiB
PHP
Raw Normal View History

2004-04-02 23:45:26 +00:00
/* SQL Database API
* By the AMX Mod X Development Team
2004-05-28 09:21:11 +00:00
* Notes - Read the comments! Make sure your plugins use
* nice ANSI SQL and don't use database column names like "key"
* otherwise this API will be a nightmare
* Never do error checking with the not operator! This is bad:
* if (!dbi_query())
* You should do:
* ret = dbi_query()
* if (ret <= 0)
* This is because DBI functions can and will return negative numbers
* Negative numbers evaluate to "true" in AMX.
2004-04-02 23:45:26 +00:00
*/
#if defined _dbi_included
#endinput
#endif
#define _dbi_included
2004-05-28 09:21:11 +00:00
/* This will return a number equal to or below 0 on failure.
* If it does fail, the error will be mirrored in dbi_error()
* The return value will otherwise be a resource handle, not an
* OK code or cell pointer.
*/
native dbi_connect(_host[], _user[], _pass[], _dbname[], _error[]="", _maxlength=0);
/* This will do a simple query execution on the SQL server.
* If it fails, it will return a number equal to or below 0
*/
native dbi_query(_sql, _query[], {Float,_}:...);
2004-04-02 23:45:26 +00:00
2004-05-28 09:21:11 +00:00
/* Returns 0 on failure or End of Results.
* Advances result pointer by one row.
*/
native dbi_nextrow(_sql);
2004-04-02 23:45:26 +00:00
2004-05-28 09:21:11 +00:00
/* Gets a field by number. Returns 0 on failure.
* Although internally fields always start from 0,
* This function takes fieldnum starting from 1.
*/
native dbi_getfield(_sql, _fieldnum, _dest[], _maxlen);
2004-04-02 23:45:26 +00:00
2004-05-28 09:21:11 +00:00
/* Closes a database handle. Internally, it will also
* mark the handle as free, so this particular handle may
* be re-used in the future to save time.
*/
native dbi_close(_sql);
2004-04-02 23:45:26 +00:00
2004-05-28 09:21:11 +00:00
/* Returns an error message set. For PGSQL and MySQL,
* this is a direct error return from the database handle/API.
* For MSSQL, it returns the last error message found from a
* thrown exception.
*/
native dbi_error(_sql, _error[], _len);
2004-04-02 23:45:26 +00:00
2004-05-28 09:21:11 +00:00
/* Returns the type of database being used. So far:
* "mysql", "pgsql", "mssql"
*/
native dbi_type(_type[], _len);