当前位置:Gxlcms > mysql > MySQL数据库函数详解(3)_MySQL

MySQL数据库函数详解(3)_MySQL

时间:2021-07-01 10:21:17 帮助过:24人阅读

  (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("

");

}

?>

人气教程排行