| SQL_AddQuery | Adds a query to a transaction object. |
| SQL_BindParamFloat | Binds a parameter in a prepared statement to a given float value. |
| SQL_BindParamInt | Binds a parameter in a prepared statement to a given integer value. |
| SQL_BindParamString | Binds a parameter in a prepared statement to a given string value. |
| SQL_CheckConfig | Returns if a named configuration is present in databases.cfg. |
| SQL_Connect | Creates an SQL connection from a named configuration. |
| SQL_ConnectCustom | Connects to a database using key value pairs containing the database info.
The key/value pairs should match what would be in databases.cfg.
I.e. "driver" should be "default" or a driver name (or omitted for
the default). For SQLite, only the "database" parameter is needed in addition.
For drivers which require external connections, more of the parameters may be
needed.
In general it is discouraged to use this function. Connections should go through
databases.cfg for greatest flexibility on behalf of users. |
| SQL_ConnectEx | |
| SQL_CreateTransaction | Creates a new transaction object. A transaction object is a list of queries
that can be sent to the database thread and executed as a single transaction. |
| SQL_DefConnect | Creates a default SQL connection. |
| SQL_EscapeString | Escapes a database string for literal insertion. This is not needed
for binding strings in prepared statements.
Generally, database strings are inserted into queries enclosed in
single quotes ('). If user input has a single quote in it, the
quote needs to be escaped. This function ensures that any unsafe
characters are safely escaped according to the database engine and
the database's character set.
NOTE: SourceMod only guarantees properly escaped strings when the query
encloses the string in single quotes. While drivers tend to allow double
quotes (") instead, the string may be not be escaped (for example, on SQLite)! |
| SQL_Execute | Executes a prepared statement. All parameters must be bound beforehand. |
| SQL_ExecuteTransaction | Sends a transaction to the database thread. The transaction handle is
automatically closed. When the transaction completes, the optional
callback is invoked. |
| SQL_FastQuery | Executes a query and ignores the result set. |
| SQL_FetchFloat | Fetches a float from a field in the current row of a result set.
If the result is NULL, a value of 0.0 will be returned. A NULL
check can be done with the result parameter, or SQL_IsFieldNull(). |
| SQL_FetchInt | Fetches an integer from a field in the current row of a result set.
If the result is NULL, a value of 0 will be returned. A NULL
check can be done with the result parameter, or SQL_IsFieldNull(). |
| SQL_FetchMoreResults | Advances to the next set of results.
In some SQL implementations, multiple result sets can exist on one query.
This is possible in MySQL with simple queries when executing a CALL
query. If this is the case, all result sets must be processed before
another query is made. |
| SQL_FetchRow | Fetches a row from the current result set. This must be
successfully called before any results are fetched.
If this function fails, SQL_MoreRows() can be used to
tell if there was an error or the result set is finished. |
| SQL_FetchSize | Returns the length of a field's data in the current row of a result
set. This only needs to be called for strings to determine how many
bytes to use. Note that the return value does not include the null
terminator. |
| SQL_FetchString | Fetches a string from a field in the current row of a result set.
If the result is NULL, an empty string will be returned. A NULL
check can be done with the result parameter, or SQL_IsFieldNull(). |
| SQL_FieldNameToNum | Retrieves a field index by name. |
| SQL_FieldNumToName | Retrieves the name of a field by index. |
| SQL_FormatQuery | Formats a string according to the SourceMod format rules (see documentation).
All format specifiers are escaped (see SQL_EscapeString) unless the '!' flag is used. |
| SQL_GetAffectedRows | Returns the number of affected rows from the last query. |
| SQL_GetDriver | Returns a driver Handle from a name string.
If the driver is not found, SourceMod will attempt
to load an extension named dbi.<name>.ext.[dll|so]. |
| SQL_GetDriverIdent | Retrieves a driver's identification string.
Example: "mysql", "sqlite" |
| SQL_GetDriverProduct | Retrieves a driver's product string.
Example: "MySQL", "SQLite" |
| SQL_GetError | Returns the error reported by the last query. |
| SQL_GetFieldCount | Retrieves the number of fields in the last result set. |
| SQL_GetInsertId | Returns the last query's insertion id. |
| SQL_GetRowCount | Retrieves the number of rows in the last result set. |
| SQL_HasResultSet | Returns whether or not a result set exists. This will
return true even if 0 results were returned, but false
on queries like UPDATE, INSERT, or DELETE. |
| SQL_IsFieldNull | Returns whether a field's data in the current row of a result set is
NULL or not. NULL is an SQL type which means "no data." |
| SQL_IsSameConnection | Tells whether two database handles both point to the same database
connection. |
| SQL_LockDatabase | Locks a database so threading operations will not interrupt.
If you are using a database Handle for both threading and non-threading,
this MUST be called before doing any set of non-threading DB operations.
Otherwise you risk corrupting the database driver's memory or network
connection.
Leaving a lock on a database and then executing a threaded query results
in a dead lock! Make sure to call SQL_UnlockDatabase()!
If the lock cannot be acquired, the main thread will pause until the
threaded operation has concluded.
Care should be taken to not lock an already-locked database. Internally,
lock calls are nested recursively and must be paired with an equal amount
of unlocks to be undone. This behaviour should not be relied on. |
| SQL_MoreRows | Returns if there are more rows. |
| SQL_PrepareQuery | Creates a new prepared statement query. Prepared statements can
be executed any number of times. They can also have placeholder
parameters, similar to variables, which can be bound safely and
securely (for example, you do not need to quote bound strings).
Statement handles will work in any function that accepts a Query handle. |
| SQL_Query | Executes a simple query and returns a new query Handle for
receiving the results. |
| SQL_QuoteString | |
| SQL_ReadDriver | Reads the driver of an opened database. |
| SQL_Rewind | Rewinds a result set back to the first result. |
| SQL_SetCharset | Sets the character set of the current connection.
Like SET NAMES .. in mysql, but stays after connection problems.
Example: "utf8", "latin1" |
| SQL_TConnect | Connects to a database via a thread. This can be used instead of
SQL_Connect() if you wish for non-blocking functionality.
It is not necessary to use this to use threaded queries. However, if you
don't (or you mix threaded/non-threaded queries), you should see
SQL_LockDatabase(). |
| SQL_TQuery | Executes a simple query via a thread. The query Handle is passed through
the callback.
The database Handle returned through the callback is always a new Handle,
and if necessary, SQL_IsSameConnection() should be used to test against
other connections.
The query Handle returned through the callback is temporary and destroyed
at the end of the callback. If you need to hold onto it, use CloneHandle(). |
| SQL_UnlockDatabase | Unlocks a database so threading operations may continue. |
| SQLite_UseDatabase | Grabs a handle to an SQLite database, creating one if it does not exist.
Unless there are extenuating circumstances, you should consider using "sourcemod-local" as the
database name. This provides some unification between plugins on behalf of users.
As a precaution, you should always create some sort of unique prefix to your table names so
there are no conflicts, and you should never drop or modify tables that you do not own. |