mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 10:58:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@153793 c90b9560-bf6c-de11-be94-00142212c4b1
214 lines
5.9 KiB
XML
214 lines
5.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.11 $ -->
|
|
<!-- EN-Revision: 1.10 Maintainer: baoengb Status: ready -->
|
|
<refentry id="function.mysqli-fetch-field">
|
|
<refnamediv>
|
|
<refname>mysqli_fetch_field</refname>
|
|
<refname>result->fetch_field</refname>
|
|
<refpurpose>Regresa metadatos de el campo en el resultado</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<para>Estilo por procedimientos:</para>
|
|
<methodsynopsis>
|
|
<type>mixto</type><methodname>mysqli_fetch_field</methodname>
|
|
<methodparam><type>objeto</type><parameter>resultado</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>Estilo orientado a objetos (método):</para>
|
|
<classsynopsis>
|
|
<ooclass><classname>resultado</classname></ooclass>
|
|
<methodsynopsis>
|
|
<type>mixto</type>
|
|
<methodname>fetch_field</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
</classsynopsis>
|
|
<para>
|
|
La función <function>mysqli_fetch_field</function> regresa un objeto
|
|
con información de definición de un campo de un resultado.
|
|
Ejecute esta función repetidamente para obtener la información
|
|
de todas las columnas en un resultado. <function>mysqli_fetch_field</function>
|
|
regresa &false; cuando no hay más columnas en el resultado.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1>
|
|
<title>Valores regresados</title>
|
|
<para>
|
|
Regresa un objeto el cual contiene la información de la definición
|
|
del campo o &false; si no hay información disponible.
|
|
</para>
|
|
<para>
|
|
<table>
|
|
<title>Atributos del objeto</title>
|
|
<tgroup cols='2'>
|
|
<thead>
|
|
<row>
|
|
<entry>Atributo</entry>
|
|
<entry>Descripción</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>name</entry>
|
|
<entry>El nombre de la columna</entry>
|
|
</row>
|
|
<row>
|
|
<entry>orgname</entry>
|
|
<entry>Nombre original de la columna, si se específico un alias</entry>
|
|
</row>
|
|
<row>
|
|
<entry>table</entry>
|
|
<entry>El nombre de la tablaa la cuál pertenece</entry>
|
|
</row>
|
|
<row>
|
|
<entry>orgtable</entry>
|
|
<entry>Nombre original de la tabla si se específico un alias</entry>
|
|
</row>
|
|
<row>
|
|
<entry>def</entry>
|
|
<entry>El valor por defecto de este campo, representado con una cadena</entry>
|
|
</row>
|
|
<row>
|
|
<entry>max_length</entry>
|
|
<entry>La máma amplitud del campo para el resultado</entry>
|
|
</row>
|
|
<row>
|
|
<entry>flags</entry>
|
|
<entry>Un entero representando los bit de bandera para el campo</entry>
|
|
</row>
|
|
<row>
|
|
<entry>type</entry>
|
|
<entry>El tipo de dato usado para este campo</entry>
|
|
</row>
|
|
<row>
|
|
<entry>decimals</entry>
|
|
<entry>El número de decimales utilizadas (para campos numéricos)</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1>
|
|
<title>Vea también</title>
|
|
<para>
|
|
<function>mysqli_num_fields</function>
|
|
<function>mysqli_fetch_field_direct</function>
|
|
<function>mysqli_fetch_fields</function>
|
|
<function>mysqli_field_seek</function>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1>
|
|
<title>Ejemplos</title>
|
|
<example>
|
|
<title>Estilo orientado a objetos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
|
|
|
|
/* check connection */
|
|
if (mysqli_connect_errno()) {
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
exit();
|
|
}
|
|
|
|
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
|
|
|
|
if ($result = $mysqli->query($query)) {
|
|
|
|
/* Get field information for all columns */
|
|
while ($finfo = $result->fetch_field()) {
|
|
|
|
printf("Name: %s\n", $finfo->name);
|
|
printf("Table: %s\n", $finfo->table);
|
|
printf("max. Len: %d\n", $finfo->max_length);
|
|
printf("Flags: %d\n", $finfo->flags);
|
|
printf("Type: %d\n\n", $finfo->type);
|
|
}
|
|
$result->close();
|
|
}
|
|
|
|
/* close connection */
|
|
$mysqli->close();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example>
|
|
<title>Estilo por procedimientos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
|
|
|
|
/* check connection */
|
|
if (mysqli_connect_errno()) {
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
exit();
|
|
}
|
|
|
|
$query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";
|
|
|
|
if ($result = mysqli_query($link, $query)) {
|
|
|
|
/* Get field information for all fields */
|
|
while ($finfo = mysqli_fetch_field($result)) {
|
|
|
|
printf("Name: %s\n", $finfo->name);
|
|
printf("Table: %s\n", $finfo->table);
|
|
printf("max. Len: %d\n", $finfo->max_length);
|
|
printf("Flags: %d\n", $finfo->flags);
|
|
printf("Type: %d\n\n", $finfo->type);
|
|
}
|
|
mysqli_free_result($result);
|
|
}
|
|
|
|
/* close connection */
|
|
mysqli_close($link);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<para>
|
|
Los ejemplos anteriores producirán la siguiente salida:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
Name: Name
|
|
Table: Country
|
|
max. Len: 11
|
|
Flags: 1
|
|
Type: 254
|
|
|
|
Name: SurfaceArea
|
|
Table: Country
|
|
max. Len: 10
|
|
Flags: 32769
|
|
Type: 4
|
|
|
|
]]>
|
|
</screen>
|
|
</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:"../../../../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
|
|
-->
|