Interested in improving this site? Please check the To Do page.
mysql.pingServer
Make sure the MySQL server is running and reachable
Syntax
mysql.pingServer(dbid)
Params
A database connection id
Returns
0 if the connection is alive
Examples
on pingtest () {
local (id);
mysql.init();
dialog.alert("Testing server. Be sure it's on.");
id = mysql.connect(id, "localhost", "root", "frontier", "frontier", 3306);
dialog.alert("Server ping: " + mysql.pingServer(id));
dialog.alert("Now, turn server off for a moment. Click OK when server is off.");
dialog.alert("Server ping: " + mysql.pingServer(id));
dialog.alert("Now, turn back on. Click OK when server is on.");
dialog.alert("Server ping: " + mysql.pingServer(id));
dialog.alert("Server ping: " + mysql.pingServer(id));
mysql.close(id);
mysql.end()}
Notes
The mysql.pingServer function attempts to reconnect if the connection went down.
The internal mysql_ping function is used in nearly all the Frontier API calls where a database connection id is passed. If the server is down mysql_ping couldn’t revive the connection, a scriptError is thrown.