mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
122 lines
3.2 KiB
XML
122 lines
3.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: ed56c4e375ef51f88d578741f1b5074d31fc0988 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandoc, leonardolara -->
|
|
<refentry xml:id="function.mysql-ping" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>mysql_ping</refname>
|
|
<refpurpose>Pinga uma conexão com o servidor ou reconecta se não houver conexão</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>
|
|
Confere se a conexão com o
|
|
servidor está funcionando ou não. Se ela tiver caído, tenta realizar uma conexão
|
|
automática. Esta função pode ser usada em scripts que permanecem inativos por
|
|
um longo tempo, para verificar se o servidor fechou ou não a conexão
|
|
e reconectar se necessário.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
A reconexão automática está desabilitada por padrão em versões do 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>
|
|
Retorna &true; se a conexão com o servidor MySQL estiver funcionando,
|
|
caso contrário retorna &false;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo <function>mysql_ping</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
set_time_limit(0);
|
|
|
|
$conn = mysql_connect('localhost', 'usuario', 'senha');
|
|
$db = mysql_select_db('mydb');
|
|
|
|
/* Supondo que esta consulta levará muito tempo */
|
|
$result = mysql_query($sql);
|
|
if (!$result) {
|
|
echo 'Consulta #1 falhou, saindo.';
|
|
exit;
|
|
}
|
|
|
|
/* Certifique-se de que a conexão ainda esteja ativa; caso contrário, tente reconectar */
|
|
if (!mysql_ping($conn)) {
|
|
echo 'Conexão perdida, saindo após consulta #1';
|
|
exit;
|
|
}
|
|
mysql_free_result($result);
|
|
|
|
/* Então a conexão ainda está ativa, vamos executar outra consulta */
|
|
$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
|
|
-->
|