2003-03-15 23:01:35 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<!-- $Revision: 1.10 $ -->
|
|
|
|
|
<!-- EN-Revision: 1.9 Maintainer: baoengb Status: ready -->
|
2003-03-15 23:01:35 +00:00
|
|
|
|
<refentry id="function.mysqli-fetch-lengths">
|
|
|
|
|
<refnamediv>
|
|
|
|
|
<refname>mysqli_fetch_lengths</refname>
|
2004-02-22 09:40:50 +00:00
|
|
|
|
<refname>result->lengths</refname>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<refpurpose>Regresa la longitud de las columnas de la fila actual en el
|
|
|
|
|
resultado</refpurpose>
|
2003-03-15 23:01:35 +00:00
|
|
|
|
</refnamediv>
|
|
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<title>Descripción</title>
|
|
|
|
|
<para>Estilo por procedimientos:</para>
|
2004-01-28 23:18:42 +00:00
|
|
|
|
<methodsynopsis>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<type>mixto</type><methodname>mysqli_fetch_lengths</methodname>
|
|
|
|
|
<methodparam><type>objeto</type><parameter>resultado</parameter></methodparam>
|
2004-01-28 23:18:42 +00:00
|
|
|
|
</methodsynopsis>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<para>Estilo orientado a objetos(propiedad):</para>
|
2004-01-28 23:18:42 +00:00
|
|
|
|
<classsynopsis>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<ooclass><classname>resultado</classname></ooclass>
|
|
|
|
|
<fieldsynopsis><type>mixto</type><varname>lengths</varname></fieldsynopsis>
|
2004-01-28 23:18:42 +00:00
|
|
|
|
</classsynopsis>
|
2003-03-15 23:01:35 +00:00
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
La funció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ámetro <parameter>result</parameter>. Si hay
|
|
|
|
|
información regresa una matriz numéricamente ordenada representando
|
|
|
|
|
la longitud de cada columna o &false; si falla.
|
2003-03-15 23:01:35 +00:00
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
2004-01-28 23:18:42 +00:00
|
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<title>Valores regresados</title>
|
2004-01-28 23:18:42 +00:00
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
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.
|
2004-01-28 23:18:42 +00:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<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és de obtener todas las filas
|
|
|
|
|
en el resultado.
|
2004-01-28 23:18:42 +00:00
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
2004-02-22 09:40:50 +00:00
|
|
|
|
<refsect1>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<title>Ejemplos</title>
|
2004-02-25 21:59:16 +00:00
|
|
|
|
<example>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<title>Estilo orientado a objetos</title>
|
2004-02-25 21:59:16 +00:00
|
|
|
|
<programlisting role="php">
|
2004-02-22 09:40:50 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
<?php
|
2004-02-25 21:59:16 +00:00
|
|
|
|
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
/* check connection */
|
|
|
|
|
if (mysqli_connect_errno()) {
|
|
|
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
$query = "SELECT * from Country ORDER BY Code LIMIT 1";
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
if ($result = $mysqli->query($query)) {
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
$row = $result->fetch_row();
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
/* 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();
|
|
|
|
|
}
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
/* close connection */
|
2004-02-22 09:40:50 +00:00
|
|
|
|
$mysqli->close();
|
|
|
|
|
?>
|
|
|
|
|
]]>
|
2004-02-25 21:59:16 +00:00
|
|
|
|
</programlisting>
|
|
|
|
|
</example>
|
|
|
|
|
<example>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
<title>Estilo por procedimientos</title>
|
2004-02-25 21:59:16 +00:00
|
|
|
|
<programlisting role="php">
|
2004-02-22 09:40:50 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
<?php
|
2004-02-25 21:59:16 +00:00
|
|
|
|
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
/* check connection */
|
|
|
|
|
if (mysqli_connect_errno()) {
|
|
|
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
$query = "SELECT * from Country ORDER BY Code LIMIT 1";
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
if ($result = mysqli_query($link, $query)) {
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
$row = mysqli_fetch_row($result);
|
2004-02-22 09:40:50 +00:00
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
/* 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);
|
2004-02-22 09:40:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-25 21:59:16 +00:00
|
|
|
|
/* close connection */
|
2004-02-22 09:40:50 +00:00
|
|
|
|
mysqli_close($link);
|
|
|
|
|
?>
|
|
|
|
|
]]>
|
2004-02-25 21:59:16 +00:00
|
|
|
|
</programlisting>
|
|
|
|
|
</example>
|
|
|
|
|
<para>
|
2004-03-16 15:26:37 +00:00
|
|
|
|
Los ejemplos anteriores producirán la siguiente salida:
|
2004-02-22 09:40:50 +00:00
|
|
|
|
</para>
|
2004-02-25 21:59:16 +00:00
|
|
|
|
<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>
|
2004-02-22 09:40:50 +00:00
|
|
|
|
</refsect1>
|
2003-03-15 23:01:35 +00:00
|
|
|
|
</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
|
|
|
|
|
-->
|