Modules/MTA-MySQL/mysql select db

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


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