php-doc-en/reference/mysqli/functions/mysqli-fetch-lengths.xml

156 lines
4.2 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- EN-Revision: 1.9 Maintainer: baoengb Status: ready -->
<refentry id="function.mysqli-fetch-lengths">
<refnamediv>
<refname>mysqli_fetch_lengths</refname>
<refname>result->lengths</refname>
<refpurpose>Regresa la longitud de las columnas de la fila actual en el
resultado</refpurpose>
</refnamediv>
<refsect1>
<title>Descripci&oacute;n</title>
<para>Estilo por procedimientos:</para>
<methodsynopsis>
<type>mixto</type><methodname>mysqli_fetch_lengths</methodname>
<methodparam><type>objeto</type><parameter>resultado</parameter></methodparam>
</methodsynopsis>
<para>Estilo orientado a objetos(propiedad):</para>
<classsynopsis>
<ooclass><classname>resultado</classname></ooclass>
<fieldsynopsis><type>mixto</type><varname>lengths</varname></fieldsynopsis>
</classsynopsis>
<para>
La funci&oacute;n <function>mysqli_fetch_lengths</function> regresa una matriz
conteniendo la longitud de cada columna de la fila actual en el resultado
representado por el par&aacute;metro <parameter>result</parameter>. Si hay
informaci&oacute;n regresa una matriz num&eacute;ricamente ordenada representando
la longitud de cada columna o &false; si falla.
</para>
</refsect1>
<refsect1>
<title>Valores regresados</title>
<para>
Una matriz de enteros representando el tama<6D>o de cada columna (sin incluir
el caracter NULL al final de la columna). &false; si ocurre un error.
</para>
<para>
<function>mysql_fetch_lengths</function>Es valida solo para la fila actual
en el resultado. Regresa &false; si se llama antes de ejecutar
mysql_fetch_row/array/object o despu&eacute;s de obtener todas las filas
en el resultado.
</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 * from Country ORDER BY Code LIMIT 1";
if ($result = $mysqli->query($query)) {
$row = $result->fetch_row();
/* display column lengths */
for ($i=0; $i < count($result->lengths); $i++) {
printf("Field %2d has Length %2d\n", $i+1, $result->lengths[$i]);
}
$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 * from Country ORDER BY Code LIMIT 1";
if ($result = mysqli_query($link, $query)) {
$row = mysqli_fetch_row($result);
/* display column lengths */
$lengths = mysqli_fetch_lengths($result);
for ($i=0; $i < count($lengths); $i++) {
printf("Field %2d has Length %2d\n", $i+1, $lengths[$i]);
}
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
Los ejemplos anteriores producir&aacute;n la siguiente salida:
</para>
<screen>
<![CDATA[
Field 1 has Length 3
Field 2 has Length 5
Field 3 has Length 13
Field 4 has Length 9
Field 5 has Length 6
Field 6 has Length 1
Field 7 has Length 6
Field 8 has Length 4
Field 9 has Length 6
Field 10 has Length 6
Field 11 has Length 5
Field 12 has Length 44
Field 13 has Length 7
Field 14 has Length 3
Field 15 has Length 2
]]>
</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
-->