Rechercher dans le manuel MySQL
28.7.7.52 mysql_ping()
int mysql_ping(MYSQL *mysql)
Description
Checks whether the connection to the server is working. If the
connection has gone down and auto-reconnect is enabled an
attempt to reconnect is made. If the connection is down and
auto-reconnect is disabled,
mysql_ping()
returns an error.
Auto-reconnect is disabled by default. To enable it, call
mysql_options()
with the
MYSQL_OPT_RECONNECT
option. For details,
see Section 28.7.7.50, “mysql_options()”.
mysql_ping()
can be used by
clients that remain idle for a long while, to check whether
the server has closed the connection and reconnect if
necessary.
If mysql_ping()
) does cause a
reconnect, there is no explicit indication of it. To determine
whether a reconnect occurs, call
mysql_thread_id()
to get the
original connection identifier before calling
mysql_ping()
, then call
mysql_thread_id()
again to see
whether the identifier has changed.
If reconnect occurs, some characteristics of the connection will have been reset. For details about these characteristics, see Section 28.7.28, “C API Automatic Reconnection Control”.
Zero if the connection to the server is active. Nonzero if an error occurred. A nonzero return does not indicate whether the MySQL server itself is down; the connection might be broken for other reasons such as network problems.
Commands were executed in an improper order.
The MySQL server has gone away.
An unknown error occurred.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-mysql-ping.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.