PHP 8.3.4 Released!

mysql_fetch_lengths

(PHP 4, PHP 5)

mysql_fetch_lengthsGet the length of each output in a result

Avviso

Questa enstensione deprecata da PHP 5.5.0, e sarà rimossa in futuro. Al suo posto, usare l'estensione MySQLi o PDO_MySQL. Vedere anche la guida MySQL: scelta dell'API e le FAQ relative per ulteriori informazioni. Le alternative a questa funzione includono:

Descrizione

mysql_fetch_lengths(resource $result): array|false

Returns an array that corresponds to the lengths of each field in the last row fetched by MySQL.

mysql_fetch_lengths() stores the lengths of each result column in the last row returned by mysql_fetch_row(), mysql_fetch_assoc(), mysql_fetch_array(), and mysql_fetch_object() in an array, starting at offset 0.

Elenco dei parametri

result

The risultato resource che che viene calcolato. Questo risultato deriva dal una chiamata a mysql_query().

Valori restituiti

An array of lengths on success o false in caso di fallimento.

Esempi

Example #1 A mysql_fetch_lengths() example

<?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);
?>

Il precedente esempio visualizzerà qualcosa simile a:

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

Vedere anche:

add a note

User Contributed Notes 1 note

up
-8
Bavo Janss
14 years ago
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.
To Top