ExecuteSQLDelete: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 22: | Line 22: | ||
===Example=== | ===Example=== | ||
This | This example deletes a table on start. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | -- Create's the table named "table" on resource start. | ||
function tableCreate() | |||
executeSQLCreateTable("table", "row TEXT") | |||
end | |||
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), tableCreate) | |||
-- Add's a command "deleterow" to delete the row called "row" | |||
function rowDelete() | |||
executeSQLDelete("table", "row") | |||
end | |||
addCommandHandler("deleterow", rowDelete) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 16:10, 8 June 2010
This function deletes any rows (from the database) that meet the specified conditions in the specified table.
The SQLite database contains globally stored data and can be used by scripts to store and retrieve data in a structured manner.
The executed SQL query is the following:
[sql]DELETE FROM <table> WHERE <conditions>
Syntax
bool executeSQLDelete ( string tableName, string conditions )
Required Arguments
- tableName: The name of the table you want to modify.
- conditions: The conditions that need to be met before a row is deleted.
Returns
The function returns a boolean which is true on success, and false on failure.
Example
This example deletes a table on start.
-- Create's the table named "table" on resource start. function tableCreate() executeSQLCreateTable("table", "row TEXT") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), tableCreate) -- Add's a command "deleterow" to delete the row called "row" function rowDelete() executeSQLDelete("table", "row") end addCommandHandler("deleterow", rowDelete)