Functions

sqlx.inc

amxmodx 1.8.2 hg65

Function Type Description
SQL_AffectedRows native Returns the number of affected rows.
SQL_Connect native Opens a database connection.
Returns an SQL handle, which must be freed.
Returns Empty_Handle on failure.
SQL_Execute native Executes a query.
Returns 1 if the query succeeded.
Returns 0 if the query failed.
NOTE: You can call this multiple times as long as its parent
connection is kept open. Each time the result set will be freed
from the previous call.
SQL_FieldNameToNum native Returns the number of a named column, or -1 if not found.
SQL_FieldNumToName native Returns the name of a column.
Errors on a bad field number.
SQL_FreeHandle native Frees an SQL handle.
The handle can be to anything (tuple, connection, query, results, etc).
If you free a database connection, it closes the connection as well.
SQL_GetAffinity native Returns which driver this plugin is currently bound to.
SQL_GetInsertId native Returns the insert id of the last INSERT query.
Returns 0 otherwise.
SQL_GetQueryString native Returns the original query string that a query handle used.
SQL_IsNull native Tells whether a specific column in the current row
is NULL or not.
SQL_MakeDbTuple native Creates a connection information tuple.
This tuple must be passed into connection routines.
Freeing the tuple is not necessary, but is a good idea if you
create many of them. You can cache these handles globally.
!!NOTE!! I have seen most people think that this connects to the DB.
Nowhere does it say this, and in fact it does not. It only caches
the connection information, the host/user/pass/etc.

The optional timeout parameter specifies how long connections should wait before
giving up. If 0, the default (which is undefined) is used.
SQL_MoreResults native Returns 1 if there are more results to be read,
0 otherwise.
SQL_NextResultSet native For queries which return multiple result sets, this advances to the next
result set if one is available. Otherwise, the current result set is
destroyed and will no longer be accessible.

This function will always return false on SQLite, and when using threaded
queries in MySQL. Nonetheless, it has the same effect of removing the last
result set.
SQL_NextRow native Advances to the next result (return value should be ignored).
SQL_NumColumns native Returns the number of columns total.
SQL_NumResults native Returns the number of rows total.
SQL_PrepareQuery native Prepares a query.
The query must always be freed.
This does not actually do the query!
SQL_QueryError native Gets information about a failed query error.
Returns the errorcode.
SQL_QuoteString native Back-quotes characters in a string for database querying.
Note: The buffer's maximum size should be 2*strlen(string) to catch
all scenarios.
SQL_QuoteStringFmt native Back-quotes characters in a string for database querying.
Note: The buffer's maximum size should be 2*strlen(string) to catch
all scenarios.
SQL_ReadResult native Retrieves the current result.
A successful query starts at the first result,
so you should not call SQL_NextRow() first.
Passing no extra params - return int
Passing one extra param - return float in 1st extra arg
Passing two extra params - return string in 1st arg, max length in 2nd
Example:
new num = SQL_ReadResult(query, 0)
new Float:num2
new str[32]
SQL_ReadResult(query, 1, num2)
SQL_ReadResult(query, 2, str, 31)
SQL_Rewind native Rewinds a result set to the first row.
SQL_SetAffinity native Sets driver affinity. You can use this to force a particular
driver implementation. This will automatically change all SQL
natives in your plugin to be "bound" to the module in question.
If no such module is found, it will return 0. This isn't necessarily bad -
the user might have typed the wrong driver. Unless your plugin is built
to handle different driver types at once, you should let this error pass.
Note, that using this while you have open handles to another database
type will cause problems. I.e., you cannot open a handle, switch
affinity, then close the handle with a different driver.
Switching affinity is an O(n*m) operation, where n is the number of
SQL natives and m is the number of used natives in total.
Intuitive programmers will note that this causes problems for threaded queries.
You will have to either force your script to work under one affinity, or to
pack the affinity type into the query data, check it against the current, then
set the new affinity if necessary. Then, restore the old for safety.
SQL_ThreadQuery native Prepares and executes a threaded query.
This will not interrupt gameplay in the event of a poor/lossed
connection, however, the interface is more complicated and
asynchronous. Furthermore, a new connection/disconnection is
made for each query to simplify driver support.
The handler should look like:
SQL_MakeStdTuple stock This function has no description.
SQL_QueryAndIgnore stock Use this for executing a query and not caring about the error.
Returns -1 on error, >=0 on success (with number of affected rows)
SQL_SimpleQuery stock Use this for executing a query where you don't care about the result.
Returns 0 on failure, 1 on success
SQL_SimpleQueryFmt stock Use this for executing a query where you don't care about the result.
Returns 0 on failure, 1 on success
sqlite_TableExists stock This function can be used to find out if a table in a Sqlite database exists.
(updated for newer API)