Modules/MTA-MySQL/mysql select db

From Multi Theft Auto: Wiki

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.


bool mysql_select_db ( MySQLConnection handler, string database )

Required arguments

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


It it succeeds returns true, in other case returns false


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))

See also