This file is to offer a little bit of coherence to our scripts. Since we’ll be dealing with all sorts of environments and setups, anything we need that might vary is defined as a wrapper stub below. All of these functions should be defined for every application implementation.
Wrapper Functions | This file is to offer a little bit of coherence to our scripts. |
wrappers | |
SQL Wrapper Functions | |
FormatAndEscapeData | Formats and escapes data from lua to be appropriate for use in SQL. |
Execute | Execute given statement on the database. |
BeginTransaction | If the SQL implementation allows it, start a transaction. |
EndTransaction | If the SQL implementation allows it, end a transaction. |
BeginTransaction | Get the number of affected rows from the last statement executed. |
File Wrapper Functions | |
FileExists | Check to see if a file or folder exists. |
FileRead | Read a file. |
FileWrite | Write to a file. |
FileDelete | Delete a file or folder. |
Command Wrappers |
SQL Wrapper Functions | |
FormatAndEscapeData | Formats and escapes data from lua to be appropriate for use in SQL. |
Execute | Execute given statement on the database. |
BeginTransaction | If the SQL implementation allows it, start a transaction. |
EndTransaction | If the SQL implementation allows it, end a transaction. |
BeginTransaction | Get the number of affected rows from the last statement executed. |
File Wrapper Functions | |
FileExists | Check to see if a file or folder exists. |
FileRead | Read a file. |
FileWrite | Write to a file. |
FileDelete | Delete a file or folder. |
Command Wrappers |
function FormatAndEscapeData( data )
Formats and escapes data from lua to be appropriate for use in SQL. This function must quote and escape strings as well as handle nil and numbers. For numbers, you probably want to pass it right back as a string. For nil, you probably want to return “NULL”.
data | The data that can be a string, number, or nil. Any other type is an error condition. |
The string of the formatted and escaped data.
v1.00 | Initial. |
function Execute( database_type, statement, key_types )
Execute given statement on the database. Note that we assume that there is only one database, and we’re automatically connected to it.
database_type | The database type to execute this statement on. See otlib.DatabaseTypes. |
statement | The string to execute on the database. If the statement doesn’t execute properly, raise an error. |
key_types | An optional table indexed by row-key string name with lua string type values (IE, “number”). This is here in case you’re dealing with a poor SQL implementation and need to convert datatypes yourself. |
Nil if it wasn’t a select operation, a list table of selected data otherwise.
v1.00 | Initial. |
Formats and escapes data from lua to be appropriate for use in SQL.
function FormatAndEscapeData( data )
Execute given statement on the database.
function Execute( database_type, statement, key_types )
If the SQL implementation allows it, start a transaction.
function BeginTransaction( database_type )
If the SQL implementation allows it, end a transaction.
function EndTransaction( database_type )
Check to see if a file or folder exists.
function FileExists( file_path )
Read a file.
function FileRead( file_path )
Write to a file.
function FileWrite( file_path, data )
Delete a file or folder.
function FileDelete( file_path )
DatabaseTypes