Classes 5

Class Description
Database

A Database represents a live connection to a database, either over the wire, through a unix domain socket, or over an open file.

DBDriver

A Driver represents a database backend, currently MySQL or SQLite.

DBResultSet

Represents a set of results returned from executing a query.

DBStatement

A DBStatement is a pre-compiled SQL query that may be executed multiple times with different parameters. A DBStatement holds a reference to the Database that prepared it.

Transaction

A Transaction is a collection of SQL statements that must all execute successfully or not at all.

Enums 3

Enum Description
DBBindType

Describes binding types.

DBPriority

Threading priority level.

DBResult

Describes a database field fetch status.

Types 5

Type Description
SQLConnectCallback

Callback for receiving asynchronous database connections.

SQLQueryCallback

Callback for receiving asynchronous database query results.

SQLTCallback

General callback for threaded SQL stuff.

SQLTxnFailure

Callback for a failed transaction.

SQLTxnSuccess

Functions 46

Function Description
SQLite_UseDatabase

Grabs a handle to an SQLite database, creating one if it does not exist.

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.

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.

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.

SQL_FetchRow

Fetches a row from the current result set. This must be successfully called before any results are fetched.

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.

SQL_GetDriverIdent

Retrieves a driver's identification string.

SQL_GetDriverProduct

Retrieves a driver's product string.

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.

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).

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.

SQL_TConnect

Connects to a database via a thread. This can be used instead of SQL_Connect() if you wish for non-blocking functionality.

SQL_TQuery

Executes a simple query via a thread. The query Handle is passed through the callback.

SQL_UnlockDatabase

Unlocks a database so threading operations may continue.