Funzione mysql_fetch_lengths() di PHP
Definizione e uso
La funzione mysql_fetch_lengths() ottiene la lunghezza di ciascun campo in una riga.
Le righe sono restituite da queste funzioni:mysql_fetch_array(),mysql_fetch_assoc(),mysql_fetch_object() o mysql_fetch_row().
Se ha successo, la funzione restituisce un array numerico, se si verifica un errore o non ci sono altre righe, restituisce false.
sintassi
mysql_fetch_lengths(data)
Parametro | Descrizione |
---|---|
data | Obbligatorio. Il puntatore dei dati da utilizzare. Il puntatore dei dati è da mysql_query() Risultato restituito. |
Esempio
<?php $con = mysql_connect("localhost", "peter", "abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person WHERE Lastname='Refsnes'"; $result = mysql_query($sql,$con); print_r(mysql_fetch_row($result)); print_r(mysql_fetch_lengths($result)); mysql_close($con); ?>
Output:
Array ( [0] => Adams [1] => John [2] => London ) Array ( [0] => 5 [1] => 4 [2] => 6 )