mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Added dbi_type()
This commit is contained in:
parent
55b57ca0cb
commit
9627b4803d
@ -296,6 +296,12 @@ static cell AMX_NATIVE_CALL mssql_error(AMX *amx, cell *params)
|
|||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL dbi_type(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return MF_SetAmxString(amx, params[1], "mssql", params[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
{
|
{
|
||||||
MF_AddNatives(mssql_Natives);
|
MF_AddNatives(mssql_Natives);
|
||||||
@ -326,6 +332,7 @@ AMX_NATIVE_INFO mssql_Natives[] = {
|
|||||||
{"dbi_nextrow", mssql_nextrow},
|
{"dbi_nextrow", mssql_nextrow},
|
||||||
{"mssql_error", mssql_error},
|
{"mssql_error", mssql_error},
|
||||||
{"dbi_error", mssql_error},
|
{"dbi_error", mssql_error},
|
||||||
|
{"dbi_type", dbi_type},
|
||||||
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
///////////////////
|
///////////////////
|
||||||
|
@ -250,6 +250,11 @@ static cell AMX_NATIVE_CALL pgsql_close(AMX *amx, cell *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL dbi_type(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return MF_SetAmxString(amx, params[1], "pgsql", params[2]);
|
||||||
|
}
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
{
|
{
|
||||||
MF_AddNatives(pgsql_exports);
|
MF_AddNatives(pgsql_exports);
|
||||||
@ -262,6 +267,7 @@ AMX_NATIVE_INFO pgsql_exports[] = {
|
|||||||
{"dbi_nextrow", pgsql_nextrow},
|
{"dbi_nextrow", pgsql_nextrow},
|
||||||
{"dbi_close", pgsql_close},
|
{"dbi_close", pgsql_close},
|
||||||
{"dbi_getfield", pgsql_getfield},
|
{"dbi_getfield", pgsql_getfield},
|
||||||
|
{"dbi_type", dbi_type},
|
||||||
{"pgsql_connect", pgsql_connect},
|
{"pgsql_connect", pgsql_connect},
|
||||||
{"pgsql_error", pgsql_error},
|
{"pgsql_error", pgsql_error},
|
||||||
{"pgsql_query", pgsql_query},
|
{"pgsql_query", pgsql_query},
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
/* SQL Database API
|
/* SQL Database API
|
||||||
* By the AMX Mod X Development Team
|
* By the AMX Mod X Development Team
|
||||||
|
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined _dbi_included
|
#if defined _dbi_included
|
||||||
@ -7,14 +17,43 @@
|
|||||||
#endif
|
#endif
|
||||||
#define _dbi_included
|
#define _dbi_included
|
||||||
|
|
||||||
native dbi_connect(host[], user[], pass[], dbname[], error[], maxlength);
|
/* 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);
|
||||||
|
|
||||||
native dbi_query(sql, query[], {Float,_}:...);
|
/* 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,_}:...);
|
||||||
|
|
||||||
native dbi_nextrow(sql);
|
/* Returns 0 on failure or End of Results.
|
||||||
|
* Advances result pointer by one row.
|
||||||
|
*/
|
||||||
|
native dbi_nextrow(_sql);
|
||||||
|
|
||||||
native dbi_getfield(sql, fieldnum, dest[], maxlen);
|
/* 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);
|
||||||
|
|
||||||
native dbi_close(sql);
|
/* 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);
|
||||||
|
|
||||||
native dbi_error(sql, error[], len);
|
/* 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);
|
||||||
|
|
||||||
|
/* Returns the type of database being used. So far:
|
||||||
|
* "mysql", "pgsql", "mssql"
|
||||||
|
*/
|
||||||
|
native dbi_type(_type[], _len);
|
||||||
|
Loading…
Reference in New Issue
Block a user