A Database represents a live connection to a database, either over the wire, through a unix domain socket, or over an open file.
| Symbol | Description |
|---|---|
| Connect | Connects to a database asynchronously, so the game thread is not blocked. |
| Escape | 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)! |
| Execute | Sends a transaction to the database thread. The transaction handle is automatically closed. When the transaction completes, the optional callback is invoked. |
| Format | Formats a string according to the SourceMod format rules (see documentation). All format specifiers are escaped (see SQL_EscapeString) unless the '!' flag is used. |
| IsSameConnection | Returns whether a database is the same connection as another database. |
| Query | Executes a query via a thread. The result handle is passed through the callback. The database handle returned through the callback is always a new Handle, and if necessary, IsSameConnection() should be used to test against other connections. The result handle returned through the callback is temporary and destroyed at the end of the callback. |
| SetCharset | Sets the character set of the connection. Like SET NAMES .. in mysql, but stays after connection problems. Example: "utf8", "latin1" |