广

MYSQL

  • MYSQL
  • MSSQL
  • Redis
  • MongoDB
  • oracle数据库
  • 数据管理

    MySQL数据库函数详解(3)

    2018-04-05 20:13:29 次阅读 稿源:互联网
    零七网广告
    全网推广平台,软文发布

      (11) object mysql_fetch_field(int result [,int col_num]);

       返回结果集中给定列的相关元数据信息,如果没有这样的列,则返回假。如果省略col_num,则对mysql_fetch_field()的后继调用返回结果集后续列的信息。如果不再有剩余的列。则返回值为假。如果指定了col_num,则其取值范围为0到mysql_num_fields()-1。在此情况下,mysql_num_fields()返回给定列的相关信息,如果col_num超出范围,返回假。

    $link=mysql_pconnect("localhost","sunsoft","suixiang")
    or die("Could not connect");

    mysql_select_db("stamp_db") or die("Could not select database");


    $query="SELECT * FROM president";

    $result=mysql_query($query) or die("Query failed");

    for($i=0;$i
    {

    printf("information for column %d:


    ",$i);

    $meta=mysql_fetch_field($result);

    if(!$meta)

    {

    print("No information available


    ");

    continue;

    }

    print("

    ");
    printf("blob: %s
    ",$meta->blob);
    printf("max_length: %s
    ",$meta->max_length);
    printf("multiple_key: %s
    ",$meta->multiple_key);
    printf("name: %s
    ",$meta->name);
    printf("not_null: %s
    ",$meta->not_null);
    printf("numeric: %s
    ",$meta->numeric);
    printf("primary_key: %s
    ",$meta->primary_key);
    printf("table: %s
    ",$meta->table);
    printf("type: %s
    ",$meta->type);
    printf("unique_key: %s
    ",$meta->unique_key);
    printf("unsigned: %s
    ",$meta->unsigned);
    printf("zerofill: %s
    ",$meta->zerofill);
    print("

    ");

    }

    ?>

    零七网部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与零七网进行文章共享合作。

    零七网广告
    零七网广告
    零七网广告
    零七网广告