mysql_field_type
(PHP 4, PHP 5, PECL mysql:1.0)
mysql_field_type — Liefert den Typ eines Feldes in einem Ergebnis
Beschreibung
string mysql_field_type
( resource $Ergebnis
, int $Feldoffset
)
mysql_field_type() ist ähnlich zu mysql_field_name(). Die Argumente sind identisch, aber stattdessen wird der Typ des Feldes zurückgegeben. Dieser kann "int", "real", "string", "blob", oder ein anderer Typ sein. Eine ausführliche Beschreibung aller Typen finden Sie in der » MySQL Dokumentation.
Example#1 mysql_field_type() Beispiel
<?php
mysql_connect("localhost", "mysql_username", "mysql_password");
mysql_select_db("mysql");
$result = mysql_query("SELECT * FROM func");
$fields = mysql_num_fields($result);
$rows = mysql_num_rows($result);
$table = mysql_field_table($result, 0);
echo "Die Tabelle '".$table."'hat ".$fields." Felder und ".$rows." Datensätze:\n";
echo "Die Tabelle hat folgende Felder:\n";
for ($i=0; $i < $fields; $i++) {
$type = mysql_field_type($result, $i);
$name = mysql_field_name($result, $i);
$len = mysql_field_len($result, $i);
$flags = mysql_field_flags($result, $i);
echo $type." ".$name." ".$len." ".$flags."\n";
}
mysql_free_result($result);
mysql_close();
?>
Das oben angeführte Beispiel führt zu dieser Ausgabe:
Die Tabelle 'func' hat 4 Felder und 1 Datensätze Die Tabelle hat folgende Felder: string name 64 not_null primary_key binary int ret 1 not_null string dl 128 not_null string type 9 not_null enum
Für Abwärtskompatibilität kann mysql_fieldtype() verwendet werden. Diese Funktion ist jedoch veraltet.