ExecuteSQLDelete: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function deletes any rows (from the database) that meet the specifiedconditions in the specified table.
{{Server function}}
{{Deprecated|executeSQLQuery|See the examples at executeSQLQuery for equivalent DELETE usage.}}
 
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 SQLite database contains globally stored data and can be used by scripts to store and retrieve data in a structured manner.
Line 10: Line 13:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool executeSQLDelete ( string table, string conditions )
bool executeSQLDelete ( string tableName, string conditions )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''table:''' The name of the table you want to modify.
*'''tableName:''' The name of the table you want to modify.
*'''conditions:''' The conditions that need to be met before a row is deleted.
*'''conditions:''' The conditions that need to be met before a row is deleted.


===Returns===
===Returns===
The function returns a ''boolean'' which is ''true'' on success, and ''false'' on failure.
The function returns a ''boolean'' which is ''true'' on success, and ''false'' on failure.
===Example===
This example creates a table and add's a command to delete the row called "row" inside the table.
<syntaxhighlight lang="lua">
-- Create's the table named "table" on resource start.
function tableCreate()
    executeSQLCreateTable("table", "row TEXT")
end
addEventHandler("onResourceStart", getResourceRootElement(), tableCreate)
-- Add's a command "deleterow" to delete the row called "row"
function rowDelete()
    executeSQLDelete("table", "row")
end
addCommandHandler("deleterow", rowDelete)
</syntaxhighlight>


==See Also==
==See Also==
{{Registry_functions}}
{{Registry_functions}}

Latest revision as of 16:24, 13 February 2015

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use executeSQLQuery instead. See the examples at executeSQLQuery for equivalent DELETE usage.


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 creates a table and add's a command to delete the row called "row" inside the table.

-- Create's the table named "table" on resource start.
function tableCreate()
    executeSQLCreateTable("table", "row TEXT")
end
addEventHandler("onResourceStart", getResourceRootElement(), tableCreate)

-- Add's a command "deleterow" to delete the row called "row"

function rowDelete()
    executeSQLDelete("table", "row")
end
addCommandHandler("deleterow", rowDelete)

See Also