Join Up!
104882 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousmysql_field_tablemysql_free_resultnext
Last updated: Mon, 28 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | Finnish | Spanish

mysql_field_type

(PHP 3, PHP 4 )

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.

Beispiel 1. MySQL-Feldtypen

<?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.

User Contributed Notes
mysql_field_type
add a note about notes
There are no user contributed notes for this page.
previousmysql_field_tablemysql_free_resultnext
Last updated: Mon, 28 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST