Modules/MTA-MySQL/mysql ping: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ Checks if the given MySQL connection is still alive. ==Syntax== <syntaxhighlight lang="lua"> bool mysql_ping ( MySQLConnection handler ) </syntaxhighlight> ===Required arguments=== * '''handler:''' A val...) |
mNo edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<pageclass class="#AA7592" subcaption="MTA-MySQL Module"></pageclass> | |||
__NOTOC__ | __NOTOC__ | ||
{{ModuleFunction|MTA-MySQL}} | |||
Checks if the given MySQL connection is still alive. | Checks if the given MySQL connection is still alive. | ||
Line 30: | Line 32: | ||
==See also== | ==See also== | ||
{{Modules/MTA-MySQL/Handler_functions}} | {{Modules/MTA-MySQL/Handler_functions}} | ||
[[RU:Modules/MTA-MySQL/mysql_ping]] |
Latest revision as of 16:21, 2 December 2017
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