|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <!-- $Revision$ --> |
3 | | -<!-- EN-Revision: 035c126c0393fe154bac46e2c3c489ebadce48a5 Maintainer: takagi Status: ready --> |
| 3 | +<!-- EN-Revision: 2cc28adf4bea27371e03ef0367ea45897cfb6446 Maintainer: takagi Status: ready --> |
4 | 4 | <!-- Credits: mumumu --> |
5 | 5 | <refentry xml:id="mysqli.get-warnings" xmlns="http://docbook.org/ns/docbook"> |
6 | 6 | <refnamediv> |
|
22 | 22 | <methodparam><type>mysqli</type><parameter>mysql</parameter></methodparam> |
23 | 23 | </methodsynopsis> |
24 | 24 |
|
25 | | - &warn.undocumented.func; |
| 25 | + <simpara> |
| 26 | + <classname>mysqli_warning</classname> |
| 27 | + で構成された単方向リンクリストを返します。 |
| 28 | + 警告がない場合は &false; を返します。 |
| 29 | + リスト中のオブジェクトはそれぞれ、 |
| 30 | + <code>SHOW WARNINGS</code> の単一行の結果からなります。 |
| 31 | + <methodname>mysqli_warning::next</methodname> |
| 32 | + をコールすると、次の行からオブジェクトを埋めます。 |
| 33 | + </simpara> |
| 34 | + <note> |
| 35 | + <simpara> |
| 36 | + 警告メッセージを取得するには、 |
| 37 | + この関数ではなく、SQLコマンド |
| 38 | + <literal>SHOW WARNINGS [limit row_count]</literal> |
| 39 | + を使うことを推奨します。 |
| 40 | + </simpara> |
| 41 | + </note> |
| 42 | + <warning> |
| 43 | + <simpara> |
| 44 | + リンクリストは、巻き戻したり、再取得したりはできません。 |
| 45 | + </simpara> |
| 46 | + </warning> |
| 47 | + </refsect1> |
| 48 | + |
| 49 | + <refsect1 role="parameters"> |
| 50 | + &reftitle.parameters; |
| 51 | + <variablelist> |
| 52 | + &mysqli.link.description; |
| 53 | + </variablelist> |
| 54 | + </refsect1> |
| 55 | + |
| 56 | + <refsect1 role="returnvalues"> |
| 57 | + &reftitle.returnvalues; |
| 58 | + <simpara> |
| 59 | + Returns a singly linked list comprised of |
| 60 | + <classname>mysqli_warning</classname> or &false; if there are no warnings. |
| 61 | + </simpara> |
| 62 | + </refsect1> |
| 63 | + |
| 64 | + <refsect1 role="examples"> |
| 65 | + &reftitle.examples; |
| 66 | + <example> |
| 67 | + <title>全ての警告を取得するために連結リストを走査する</title> |
| 68 | + |
| 69 | + <para>&style.oop;</para> |
| 70 | + <programlisting role="php"> |
| 71 | +<![CDATA[ |
| 72 | +<?php |
| 73 | +
|
| 74 | +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); |
| 75 | +$mysqli = new mysqli("localhost", "my_user", "my_password", "world"); |
| 76 | +
|
| 77 | +$mysqli->query("SELECT 1/0, CAST('NULL' AS UNSIGNED)"); |
| 78 | +
|
| 79 | +if ($mysqli->warning_count > 0) { |
| 80 | + $warning = $mysqli->get_warnings(); |
| 81 | + if ($warning !== false) { |
| 82 | + do { |
| 83 | + printf("Error number: %s\n", $warning->errno); |
| 84 | + printf("Message: %s\n", $warning->message); |
| 85 | + } while ($warning->next()); |
| 86 | + } |
| 87 | +} |
| 88 | +]]> |
| 89 | + </programlisting> |
| 90 | + <para>&style.procedural;</para> |
| 91 | + <programlisting role="php"> |
| 92 | +<![CDATA[ |
| 93 | +<?php |
| 94 | +
|
| 95 | +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); |
| 96 | +$link = mysqli_connect("localhost", "user", "password", "test"); |
| 97 | +
|
| 98 | +mysqli_query($link, "SELECT 1/0, CAST('NULL' AS UNSIGNED)"); |
| 99 | +
|
| 100 | +if (mysqli_warning_count($link) > 0) { |
| 101 | + $warning = mysqli_get_warnings($link); |
| 102 | + if ($warning !== false) { |
| 103 | + do { |
| 104 | + printf("Error number: %s\n", $warning->errno); |
| 105 | + printf("Message: %s\n", $warning->message); |
| 106 | + } while ($warning->next()); |
| 107 | + } |
| 108 | +} |
| 109 | +]]> |
| 110 | + </programlisting> |
| 111 | + &examples.outputs; |
| 112 | + <screen> |
| 113 | +<![CDATA[ |
| 114 | +Error number: 1365 |
| 115 | +Message: Division by 0 |
| 116 | +Error number: 1292 |
| 117 | +Message: Truncated incorrect INTEGER value: 'NULL' |
| 118 | +]]> |
| 119 | + </screen> |
| 120 | + </example> |
26 | 121 | </refsect1> |
27 | 122 |
|
28 | 123 | </refentry> |
|
0 commit comments