Skip to content

extDB3 sql_custom.ini

SteezCram edited this page Aug 19, 2020 · 2 revisions

SQL_CUSTOM INI

Below is ini format for SQL_CUSTOM

INI File has a default section

[Default]

Version = 1  
;; Used incase there is ever a breaking change, or to inform user in log about a new feature.

Strip Chars = ";[]"
;; List of characters to strip out  
Strip Chars Mode = 0
;; 0 = Strip Bad Chars, 1 = Strip + Log Bad Chars, 2 = Return Error & Log Bad Chars  
;;     Note: Logging on works when sending data to database.

Input SQF Parser = false  
;; Expermential  
;;   If enabled will use SQF Array Parser instead of : seperator for values  
;;   i.e   0:SQL:UpdatePlayer:["Joe",[1,2,0],0.22333,"PlayerBackpack",-3]  
;;   Advantage is that you don't need to strip : seperator from user inputted values  

Number of Retrys = 5  
;; Number of Retrys if Error Encountered  
;;  Note: If doing multiple SQL i.e SQL1_1 SQL2_1 etc, it will retry everything.  

After [Default] is setup, all the other sections are various calls i.e Predefined SQL/Prepared Statements. This is alot more secure that allowing armaserver to directly create SQL/Prepared Statements to run.

Example of a simple Prepared Statement

[getPlayerSave]
;; Prepared Statement = true
;;   If set to false, uses SQL instead of Prepared Statement
;; Return InsertID = false

;; Strip Chars = ""
;; Strip Chars Mode = 0
;;    Incase you want to override the Strip Chars from [Default]

SQL1_1 = SELECT * FROM PlayerSave WHERE PlayerUID = ? AND MapID = ?;
SQL1_INPUTS = 1,2

[getName]
SQL1_1 = SELECT name FROM Players WHERE uid = ?
SQL1_INPUTS = 1
OUTPUT = 1-STRING

Example if it was SQL Statement

[getPlayerSave]
Prepared Statement = false
;;   If set to false, uses SQL instead of Prepared Statement
;; Return InsertID = false
;; Return InsertID String = false

;; Strip Chars = ""
;; Strip Chars Mode = 0
;;    Incase you want to override the Strip Chars from [Default]

SQL1_1 = SELECT * FROM PlayerSave WHERE PlayerUID = "$CUSTOM_1$" AND MapID = "$CUSTOM_2$";
SQL1_INPUTS = 1-mysql_escape, 2-mysql_escape

Notice the option(s) assigned to SQL1_INPUTS 1 + 2, it tells it use mysql_escape on the inputs. There are various options listed at bottom of this page, you can use multiple options on single input value. Also note you can mix up the order & reuse input values for example

SQL1_INPUT= 3, 2-option1-option2-option10, 1, 2

What is Return InsertID ???*

Returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement. Instead of , you receive [,<Result]. Return InsertID String is just the number wrapped in quotations to avoid arma floating number precision issues, numbers with more than 6 digits in length i.e 1234567

###What is SQLX_Y ???

X = Line Number
Y = Line Part Number

This allows you to split up SQL Line into multiple lines to help make the ini file more readable. The reason for X is because running multiple SQL Lines in a single Line is disabled for security reasons.

What is SQLX_INPUT ???

X = Line Number

Allows you define specfic input options for each SQL Line, incase you have created multiple SQL config.

What is OUTPUT ???

Define output options Note: Only Returns values from last SQL line if you are running multiple SQLX_Y

List of Input/Output Options

Case-insensitive

beguid

Converts SteamID into BattlEye GUID.

bool

Converts bool

null

Converts null SQL Input -> If empty string, changed to MySQL Null (its objNull in RAW SQL) SQL Output -> If NULL changes it to objNull.

time

Prepared Statement -> Only for sending, converts [year,month,day,hour,minute,second] to MySQL TIME. extDB3 automatically converts time when fetching from Database.

string

Wraps string with "

string2

Wraps string with '

strip

Override Strips Chars on value

mysql_escape

For use only with SQL not Prepared Statements.

New in v 1.031

remove_quotes Strips " ' from the result

New in v 1.011

add_escape_quotes

Replace " with ""

remove_escape_quotes

Replaces "" with "

Obsolete in v 1.011

string_escape_quotes

Escapes " -> "" Added " to either end of string

So for example aaa'bbb"dsadsd" -> "aaa''bbb""dsadsd""" so it will call compile correctly Useful for when storing + retreiving playernames from Database

string_escape_quotes2

Escapes " -> "" Added ' to either end of string