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

search for in the

mysql_fetch_object> <mysql_fetch_field
Last updated: Fri, 22 Aug 2008

view this page in

mysql_fetch_lengths

(PHP 4, PHP 5, PECL mysql:1.0)

mysql_fetch_lengthsObtém o tamanho de cada saída no resultado

Descrição

array mysql_fetch_lengths ( resource $result )

Retorna uma matriz que corresponde aos tamanhos de cada campo na ultima linha obtida pelo MySQL.

mysql_fetch_lengths() guarda o tamanho de cada coluna do resultado na ultima linha retornada por mysql_fetch_row(), mysql_fetch_assoc(), mysql_fetch_array(), e mysql_fetch_object() em uma matriz, começando no índice 0.

Parâmetros

result

O resultado resource que esta sendo avaliado. Este resultado vem de uma chamada a mysql_query().

Valor Retornado

Um array de tamanhos em caso de sucesso, ou FALSE em caso de falha.

Exemplos

Exemplo #1 Um exemplo mysql_fetch_lengths()

<?php
$result 
mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!
$result) {
    echo 
'Não foi possível executar a consulta: ' mysql_error();
    exit;
}
$row     mysql_fetch_assoc($result);
$lengths mysql_fetch_lengths($result);

print_r($row);
print_r($lengths);
?>

O exemplo acima irá imprimir algo similar a:

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



add a note add a note User Contributed Notes
mysql_fetch_lengths
10-Feb-2006 03:23
For the maximum length of a field (e.g. 10 for a VARCHAR(10) field), use mysql_field_len().

mysql_fetch_object> <mysql_fetch_field
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites