executeSQLQuery | Multi Theft Auto: Wiki Skip to content

executeSQLQuery

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function executes an arbitrary SQL query and returns the result rows if there are any. It allows parameter binding for security (SQL injection is rendered impossible).

Note

This function only acts upon registry.db. Use dbQuery to query a custom SQL database.

Syntax

table executeSQLQuery ( string query, var param1 [, var param2 ... ] )
Required Arguments
  • query: An SQL query. Positions where parameter values will be inserted are marked with a "?".
  • param1 [, var param2 ... ]: MISSING_PARAM_DESC

Returns

  • table: value

Returns a table with the result of the query if it was a SELECT query, or false if otherwise. In case of a SELECT query the result table may be empty (if there are no result rows). The table is of the form:

Code Examples

shared

Example equivalents for executeSQLCreateTable:

executeSQLQuery("CREATE TABLE IF NOT EXISTS players (clothes_head_texture TEXT, clothes_head_model TEXT, name TEXT)")
executeSQLQuery("CREATE TABLE IF NOT EXISTS `players` (`clothes_head_texture` TEXT, `clothes_head_model` TEXT, `name` TEXT)")

See Also

Database Functions