ExecuteSQLDropTable: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function drops an existing table in the registry.
{{Server function}}
{{Deprecated|executeSQLQuery|See the examples at executeSQLQuery for equivalent DROP TABLE usage.}}


The actual SQL query that is executed will be the following:
This function drops a table in the registry. This function doesn't do anything when the table doesn't exist.


<pre>DROP TABLE IF EXISTS <table></pre>
The executed SQL query is the following:
 
<syntaxhighlight>DROP TABLE table</syntaxhighlight>


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
nil createRegistryTable ( string table )
bool executeSQLDropTable ( string tableName )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''table:''' The table you want to drop.
*'''tableName:''' The name of the table you want to drop.


===Returns===
===Returns===
The function doesn't return anything.
The function returns ''true'' on success, and ''false'' on failure.
 
===Example===
This example lets you drop an SQL table with the command: dropsqltable. Note: This command should be restricted to admins if you use it.
<syntaxhighlight lang="lua">
function removeSQLTable(thePlayer, command, SQLtable)
if (SQLtable) then -- Make sure the player entered an argument.
success = executeSQLDropTable(SQLtable) -- Drop the table
if (success) then -- If executeSQLDropTable returns true, it passes this if check to display a confirmation message
outputChatBox("SQL Table "..SQLtable.." successfully dropped.", thePlayer, 0, 255, 0)
else
outputChatBox("SQL Table "..SQLtable.." was not successfully dropped.", thePlayer, 255, 0, 0)
end
end
end
addCommandHandler("dropsqltable", removeSQLTable)
</syntaxhighlight>


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

Latest revision as of 22:08, 1 October 2016

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 DROP TABLE usage.


This function drops a table in the registry. This function doesn't do anything when the table doesn't exist.

The executed SQL query is the following:

DROP TABLE table

Syntax

bool executeSQLDropTable ( string tableName )

Required Arguments

  • tableName: The name of the table you want to drop.

Returns

The function returns true on success, and false on failure.

Example

This example lets you drop an SQL table with the command: dropsqltable. Note: This command should be restricted to admins if you use it.

function removeSQLTable(thePlayer, command, SQLtable)
	if (SQLtable) then -- Make sure the player entered an argument.
		success = executeSQLDropTable(SQLtable) -- Drop the table
		if (success) then -- If executeSQLDropTable returns true, it passes this if check to display a confirmation message
			outputChatBox("SQL Table "..SQLtable.." successfully dropped.", thePlayer, 0, 255, 0)
		else
			outputChatBox("SQL Table "..SQLtable.." was not successfully dropped.", thePlayer, 255, 0, 0)
		end
	end
end
addCommandHandler("dropsqltable", removeSQLTable)

See Also