downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_fetch_object> <mysql_fetch_field
[edit] Last updated: Fri, 25 May 2012

view this page in

mysql_fetch_lengths

(PHP 4, PHP 5)

mysql_fetch_lengthsObtiene la longitud de cada salida en un resultado

Descripción

array mysql_fetch_lengths ( resource $result )

Devuelve un array que corresponde a las longitudes de cada campo en la última fila recuperada por MySQL.

mysql_fetch_lengths() almacena las longitudes de cada columna del resultado en la última fila devuelta mediante mysql_fetch_row(), mysql_fetch_assoc(), mysql_fetch_array(), y mysql_fetch_object() en un array, comenzando desde el número 0.

Parámetros

result

El resultado resource que está siendo evaluado. Este resultado proviene de una llamada a mysql_query().

Valores devueltos

Un array de longitudes en caso de éxito o FALSE en caso de error.

Ejemplos

Ejemplo #1 Un ejemplo de mysql_fetch_lengths()

<?php
            $result 
mysql_query("SELECT id,email FROM people WHERE id = '42'");
            if (!
$result) {
            echo 
'Could not run query: ' mysql_error();
            exit;
            }
            
$row     mysql_fetch_assoc($result);
            
$lengths mysql_fetch_lengths($result);
            
            
print_r($row);
            
print_r($lengths);
            
?>

El resultado del ejemplo sería algo similar a:

         Array
         (
         [id] => 42
       [email] => user@example.com
       )
       Array
       (
       [0] => 2
       [1] => 16
       )
       

Ver también



add a note add a note User Contributed Notes mysql_fetch_lengths
Bavo Janss 10-Jul-2009 07:19
In case of UTF8 fields mysql_field_len() will return 3 times the maximum length (e.g. 30 for a VARCHAR(10) field)) for mysql_field_len() returns the byte length of the field not the defined size.
09-Feb-2006 06:23
For the maximum length of a field (e.g. 10 for a VARCHAR(10) field), use mysql_field_len().

 
show source | credits | sitemap | contact | advertising | mirror sites