(PHP 4, PHP 5)
mysql_list_fields — List MySQL table fields
Questa funzione è stata deprecata in PHP 5.4.0, ed essa e l'intera estensione MySQL originale sono state rimosse in PHP 7.0.0. Al suo posto, usare l'estensione MySQLi o PDO_MySQL, entrambe attivamente sviluppate. Vedere anche la guida MySQL: scelta dell'API. Le alternative a questa funzione includono:
SHOW COLUMNS FROM sometable$database_name, string $table_name, resource $link_identifier = NULL): resourceRetrieves information about the given table name.
This function is deprecated. It is preferable to use
mysql_query() to issue an SQL SHOW COLUMNS FROM
table [LIKE 'name'] statement instead.
database_nameThe name of the database that's being queried.
table_nameThe name of the table that's being queried.
link_identifierLa connessione MySQL. Se
l'identificativo di connessione non è specificato, viene usata l'ultima connessione aperta da
mysql_connect(). Se tale connessione non viene trovata, si
cercherà di crearne una come se mysql_connect() fosse stata chiamata
senza argomenti. Se nessuna connessione viene trovata o stabilita, viene generato un
errore di livello E_WARNING.
A result pointer resource on success, or false on
failure.
The returned result can be used with mysql_field_flags(), mysql_field_len(), mysql_field_name() e mysql_field_type().
Example #1 Alternate to deprecated mysql_list_fields()
<?php
$result = mysql_query("SHOW COLUMNS FROM sometable");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
}
}
?>Il precedente esempio visualizzerà qualcosa di simile a:
Array
(
[Field] => id
[Type] => int(7)
[Null] =>
[Key] => PRI
[Default] =>
[Extra] => auto_increment
)
Array
(
[Field] => email
[Type] => varchar(100)
[Null] =>
[Key] =>
[Default] =>
[Extra] =>
)
Nota:
Per la compatibilità all'indietro, è possibile utilizzare il seguente sinonimo deprecato: mysql_listfields()