php-doc-en/reference/mysql/functions/mysql-ping.xml
Adam Harvey 65e697ff67 Officially deprecate ext/mysql in the manual.
Specific changes:

- Upgraded the soft deprecation sidebars to full blown warnings.
- Beefed up the wording of the soft deprecation notice boilerplate.
- Added changelog items for mysql_connect() and mysql_pconnect(), since they're
  the functions that have changed behaviour.
- Updated the MySQL changelog.
- Updated the 5.5 migration guide.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328734 c90b9560-bf6c-de11-be94-00142212c4b1
2012-12-10 15:22:07 +00:00

121 lines
3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mysql-ping" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mysql_ping</refname>
<refpurpose>Ping a server connection or reconnect if there is no connection</refpurpose>
</refnamediv>
<refsynopsisdiv>
<warning>
&mysql.alternative.note;
<simplelist role="alternatives">
<member><function>mysqli_ping</function></member>
</simplelist>
</warning>
</refsynopsisdiv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>mysql_ping</methodname>
<methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter><initializer>NULL</initializer></methodparam>
</methodsynopsis>
<para>
Checks whether or not the connection to
the server is working. If it has gone down, an automatic reconnection is
attempted. This function can be used by scripts that remain idle for a
long while, to check whether or not the server has closed the connection
and reconnect if necessary.
</para>
<note>
<para>
Automatic reconnection is disabled by default in versions of MySQL >= 5.0.3.
</para>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&mysql.linkid.description;
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if the connection to the server MySQL server is working,
otherwise &false;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>mysql_ping</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
set_time_limit(0);
$conn = mysql_connect('localhost', 'mysqluser', 'mypass');
$db = mysql_select_db('mydb');
/* Assuming this query will take a long time */
$result = mysql_query($sql);
if (!$result) {
echo 'Query #1 failed, exiting.';
exit;
}
/* Make sure the connection is still alive, if not, try to reconnect */
if (!mysql_ping($conn)) {
echo 'Lost connection, exiting after query #1';
exit;
}
mysql_free_result($result);
/* So the connection is still alive, let's run another query */
$result2 = mysql_query($sql2);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mysql_thread_id</function></member>
<member><function>mysql_list_processes</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->