Modules/MTA-MySQL/mysql select db

From Multi Theft Auto: Wiki
Revision as of 17:58, 14 January 2008 by Ryden (talk | contribs)
Jump to navigation Jump to search


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