Modules/MTA-MySQL/mysql select db: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<pageclass class="#AA7592" subcaption="MTA-MySQL Module"></pageclass>
__NOTOC__
__NOTOC__
{{ModuleFunction|MTA-MySQL}}
{{ModuleFunction|MTA-MySQL}}

Revision as of 17:40, 5 January 2011


Package-x-generic.png This function is provided by the external module MTA-MySQL. You must install this module to use this function.

Changes the current default database.

Syntax

bool mysql_select_db ( MySQLConnection handler, string database )

Required arguments

  • handler: A valid MySQL link
  • database: The new database name

Returns

It it succeeds returns true, in other case returns false

Example

Example 1: This example changes the current default database to another one

local handler = mysql_connect("localhost", "user", "password", "mta_users")
if ( not mysql_select_db(handler, "another_database") ) then
  outputDebugString("Unable to change default database: (" .. mysql_errno(handler) .. ") " .. mysql_error(handler))
end

See also