Modules/MTA-MySQL/mysql ping
From Multi Theft Auto: Wiki
This function is provided by the external module MTA-MySQL. You must install this module to use this function. | |
Checks if the given MySQL connection is still alive.
Syntax
bool mysql_ping ( MySQLConnection handler )
Required arguments
- handler: A valid MySQL link
Returns
true is the connection is still alive, false if not.
Example
Example 1: This example checks if the MySQL connection is still alive when a player connects, to be able to fetch their data.
myhandler = mysql_connect("localhost", "user", "password", "mta_users") function checkMySQLConnection ( ) if (mysql_ping(myhandler) == false) then -- We lost the connection to the MySQL server outputDebugString("Lost connection to the MySQL server, reconnecting ...") mysql_close(myhandler) myhandler = mysql_connect("localhost", "user", "password", "mta_users") -- Reconnect to the MySQL server end end addEventHandler("onPlayerJoin", getRootElement(), checkMySQLConnection)
See also
- mysql_connect
- mysql_close
- mysql_errno
- mysql_error
- mysql_ping
- mysql_select_db
- mysql_escape_string
- mysql_affected_rows
- mysql_change_user
- mysql_get_character_set_info
- mysql_get_client_info
- mysql_get_client_version
- mysql_get_host_info
- mysql_get_proto_info
- mysql_get_server_info
- mysql_get_server_version
- mysql_hex_string
- mysql_info
- mysql_insert_id
- mysql_query
- mysql_unbuffered_query
- mysql_set_character_set
- mysql_stat
- mysql_warning_count