ExecuteSQLDropTable: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:


===Example===
===Example===
This page does not currently have an 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">
<syntaxhighlight lang="lua">
--enter an example here
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>
</syntaxhighlight>


==See Also==
==See Also==
{{Registry_functions}}
{{Registry_functions}}
[[Category:Needs_Example]]

Revision as of 13:22, 8 August 2010

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:

[sql]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