|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- $Revision$ --> |
| 3 | +<!-- EN-Revision: 64fe9c6c775dbf44fdc1742076d87c7f08dc540c Maintainer: seros Status: ready --> |
| 4 | +<!-- Reviewed: no --> |
| 5 | +<refentry xml:id="mysqli-driver.report-mode" xmlns="http://docbook.org/ns/docbook"> |
| 6 | + <refnamediv> |
| 7 | + <refname>mysqli_driver::$report_mode</refname> |
| 8 | + <refname>mysqli_report</refname> |
| 9 | + <refpurpose>Habilita o desabilita las funciones internas de notificación</refpurpose> |
| 10 | + </refnamediv> |
| 11 | + |
| 12 | + <refsect1 role="description"> |
| 13 | + &reftitle.description; |
| 14 | + <para>&style.oop;</para> |
| 15 | + <fieldsynopsis> |
| 16 | + <type>int</type><varname linkend="mysqli-driver.report-mode">mysqli_driver->report_mode</varname> |
| 17 | + </fieldsynopsis> |
| 18 | + <para>&style.procedural;</para> |
| 19 | + <methodsynopsis> |
| 20 | + <type>bool</type><methodname>mysqli_report</methodname> |
| 21 | + <methodparam><type>int</type><parameter>flags</parameter></methodparam> |
| 22 | + </methodsynopsis> |
| 23 | + <para> |
| 24 | + Una función útil para mejorar consultas durante el desarrollo de código y pruebas. |
| 25 | + Dependiendo de las banderas, notifica errores desde llamadas a funciones de mysqli o |
| 26 | + consultas que no usan un índice (o usan uno erróneo). |
| 27 | + </para> |
| 28 | + </refsect1> |
| 29 | + |
| 30 | + <refsect1 role="parameters"> |
| 31 | + &reftitle.parameters; |
| 32 | + <para> |
| 33 | + <variablelist> |
| 34 | + <varlistentry> |
| 35 | + <term><parameter>flags</parameter></term> |
| 36 | + <listitem> |
| 37 | + <para> |
| 38 | + <table> |
| 39 | + <title>Banderas admitidas</title> |
| 40 | + <tgroup cols="2"> |
| 41 | + <thead> |
| 42 | + <row> |
| 43 | + <entry>Nombre</entry> |
| 44 | + <entry>Descripción</entry> |
| 45 | + </row> |
| 46 | + </thead> |
| 47 | + <tbody> |
| 48 | + <row> |
| 49 | + <entry><constant>MYSQLI_REPORT_OFF</constant></entry> |
| 50 | + <entry>Desactiva la notificación</entry> |
| 51 | + </row> |
| 52 | + <row> |
| 53 | + <entry><constant>MYSQLI_REPORT_ERROR</constant></entry> |
| 54 | + <entry>Notifica errores desde llamadas a funciones de mysqli</entry> |
| 55 | + </row> |
| 56 | + <row> |
| 57 | + <entry><constant>MYSQLI_REPORT_STRICT</constant></entry> |
| 58 | + <entry> |
| 59 | + Lanza una <classname>mysqli_sql_exception</classname> para errors |
| 60 | + en lugar de para advertencias |
| 61 | + </entry> |
| 62 | + </row> |
| 63 | + <row> |
| 64 | + <entry><constant>MYSQLI_REPORT_INDEX</constant></entry> |
| 65 | + <entry>Notifica si no se usó un índice o si era erróneo en una consulta </entry> |
| 66 | + </row> |
| 67 | + <row> |
| 68 | + <entry><constant>MYSQLI_REPORT_ALL</constant></entry> |
| 69 | + <entry>Establece todas las opciones (notifica todo)</entry> |
| 70 | + </row> |
| 71 | + </tbody> |
| 72 | + </tgroup> |
| 73 | + </table> |
| 74 | + </para> |
| 75 | + </listitem> |
| 76 | + </varlistentry> |
| 77 | + </variablelist> |
| 78 | + </para> |
| 79 | + </refsect1> |
| 80 | + |
| 81 | + <refsect1 role="returnvalues"> |
| 82 | + &reftitle.returnvalues; |
| 83 | + <para> |
| 84 | + &return.success; |
| 85 | + </para> |
| 86 | + </refsect1> |
| 87 | + |
| 88 | + <refsect1 role="changelog"> |
| 89 | + &reftitle.changelog; |
| 90 | + <para> |
| 91 | + <informaltable> |
| 92 | + <tgroup cols="2"> |
| 93 | + <thead> |
| 94 | + <row> |
| 95 | + <entry>&Version;</entry> |
| 96 | + <entry>&Description;</entry> |
| 97 | + </row> |
| 98 | + </thead> |
| 99 | + <tbody> |
| 100 | + <row> |
| 101 | + <entry>5.3.4</entry> |
| 102 | + <entry> |
| 103 | + El cambio de modo de notificación ahora es por solicitud, en vez de por proceso. |
| 104 | + </entry> |
| 105 | + </row> |
| 106 | + <row> |
| 107 | + <entry>5.2.15</entry> |
| 108 | + <entry> |
| 109 | + El cambio de modo de notificación ahora es por solicitud, en vez de por proceso. |
| 110 | + </entry> |
| 111 | + </row> |
| 112 | + </tbody> |
| 113 | + </tgroup> |
| 114 | + </informaltable> |
| 115 | + </para> |
| 116 | + </refsect1> |
| 117 | + |
| 118 | + <refsect1 role="examples"> |
| 119 | + &reftitle.examples; |
| 120 | + <example> |
| 121 | + <title>&style.oop;</title> |
| 122 | + <programlisting role="php"> |
| 123 | +<![CDATA[ |
| 124 | +<?php |
| 125 | +
|
| 126 | +$mysqli = new mysqli("localhost", "mi_usuario", "mi_contraseña", "world"); |
| 127 | +
|
| 128 | +/* verificar la conexión */ |
| 129 | +if (mysqli_connect_errno()) { |
| 130 | + printf("Falló la conexión: %s\n", mysqli_connect_error()); |
| 131 | + exit(); |
| 132 | +} |
| 133 | +
|
| 134 | +/* activar la notificación */ |
| 135 | +$controlador = new mysqli_driver(); |
| 136 | +$controlador->report_mode = MYSQLI_REPORT_ALL; |
| 137 | +
|
| 138 | +try { |
| 139 | +
|
| 140 | + /* esta consulta debería notificar un error */ |
| 141 | + $resultado = $mysqli->query("SELECT Name FROM Nonexistingtable WHERE population > 50000"); |
| 142 | +
|
| 143 | + /* esta consulta debería notificar un índice erróneo */ |
| 144 | + $resultado = $mysqli->query("SELECT Name FROM City WHERE population > 50000"); |
| 145 | +
|
| 146 | + $resultado->close(); |
| 147 | +
|
| 148 | + $mysqli->close(); |
| 149 | +
|
| 150 | +} catch (mysqli_sql_exception $e) { |
| 151 | +
|
| 152 | + echo $e->__toString(); |
| 153 | +} |
| 154 | +?> |
| 155 | +]]> |
| 156 | + </programlisting> |
| 157 | + </example> |
| 158 | + <example> |
| 159 | + <title>&style.procedural;</title> |
| 160 | + <programlisting role="php"> |
| 161 | +<![CDATA[ |
| 162 | +<?php |
| 163 | +/* activar la notificación */ |
| 164 | +mysqli_report(MYSQLI_REPORT_ALL); |
| 165 | +
|
| 166 | +$enlace = mysqli_connect("localhost", "mi_usuario", "mi_contraseña", "world"); |
| 167 | +
|
| 168 | +/* verificar la conexión */ |
| 169 | +if (mysqli_connect_errno()) { |
| 170 | + printf("Falló la conexión: %s\n", mysqli_connect_error()); |
| 171 | + exit(); |
| 172 | +} |
| 173 | +
|
| 174 | +/* esta consulta debería notificar un error */ |
| 175 | +$resultado = mysqli_query("SELECT Name FROM Nonexistingtable WHERE population > 50000"); |
| 176 | +
|
| 177 | +/* esta consulta debería notificar un índice erróneo */ |
| 178 | +$resultado = mysqli_query("SELECT Name FROM City WHERE population > 50000"); |
| 179 | +
|
| 180 | +mysqli_free_result($resultado); |
| 181 | +
|
| 182 | +mysqli_close($enlace); |
| 183 | +?> |
| 184 | +]]> |
| 185 | + </programlisting> |
| 186 | + </example> |
| 187 | + </refsect1> |
| 188 | + |
| 189 | + <refsect1 role="seealso"> |
| 190 | + &reftitle.seealso; |
| 191 | + <para> |
| 192 | + <simplelist> |
| 193 | + <member><function>mysqli_debug</function></member> |
| 194 | + <member><function>mysqli_dump_debug_info</function></member> |
| 195 | + <member><classname>mysqli_sql_exception</classname></member> |
| 196 | + <member><function>set_exception_handler</function></member> |
| 197 | + <member><function>error_reporting</function></member> |
| 198 | + </simplelist> |
| 199 | + </para> |
| 200 | + </refsect1> |
| 201 | + |
| 202 | +</refentry> |
| 203 | + |
| 204 | +<!-- Keep this comment at the end of the file |
| 205 | +Local variables: |
| 206 | +mode: sgml |
| 207 | +sgml-omittag:t |
| 208 | +sgml-shorttag:t |
| 209 | +sgml-minimize-attributes:nil |
| 210 | +sgml-always-quote-attributes:t |
| 211 | +sgml-indent-step:1 |
| 212 | +sgml-indent-data:t |
| 213 | +indent-tabs-mode:nil |
| 214 | +sgml-parent-document:nil |
| 215 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 216 | +sgml-exposed-tags:nil |
| 217 | +sgml-local-catalogs:nil |
| 218 | +sgml-local-ecat-files:nil |
| 219 | +End: |
| 220 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 221 | +vim: et tw=78 syn=sgml |
| 222 | +vi: ts=1 sw=1 |
| 223 | +--> |
0 commit comments