Files
php-doc-ru/reference/pdo_mysql/pdo/mysql/getwarningcount.xml
2024-12-12 10:56:14 +03:00

89 lines
2.7 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 99abc143277b0533c19fcc94ed8dc834ef830382 Maintainer: malferov Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="pdo-mysql.getwarningcount" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>Pdo\Mysql::getWarningCount</refname>
<refpurpose>Возвращает количество предупреждений из последнего выполненного запроса</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="Pdo\\Mysql">
<modifier>public</modifier> <type>int</type><methodname>Pdo\Mysql::getWarningCount</methodname>
<void/>
</methodsynopsis>
<simpara>
Метод возвращает количество предупреждений из последнего выполненного запроса
</simpara>
<note>
<simpara>
Сообщения с предупреждениями также возвращает следующая SQL-команда:
<literal>SHOW WARNINGS [limit row_count]</literal>.
</simpara>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Метод возвращает значение с типом <type>int</type>, которое представляет количество предупреждений, сгенерированных последним запросом.
</simpara>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example xml:id="pdo-mysql.getwarningcount.example.basic">
<title>Пример получения предупреждений в последнем запросе методом <methodname>Pdo\Mysql::getWarningCount</methodname></title>
<programlisting role="php">
<![CDATA[
<?php
$conn = PDO::connect("mysql:host=localhost;dbname=test;charset=utf8mb4", 'user', 'password');
$conn->query('SELECT 42/0');
if ($conn->getWarningCount() > 0) {
$result = $conn->query("SHOW WARNINGS");
$row = $result->fetch();
printf("%s (%d): %s\n", $row[0], $row[1], $row[2]);
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Warning (1365): Division by 0
]]>
</screen>
</example>
</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
-->