(16) int mysql_field_seek(int result, int field_offset);
為隨後的mysql_fetch_field()調用設置索引。發布沒有明確列號的mysql_fetch_field()的下一次調用,將返回列col_num的信息。如果搜索成功,返回真,否則返回假。
col_num的范圍為0到mysql_num_fields()-1.
<?php
$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<mysql_num_fields($result);$i++)
{
printf("Information for column %d:<BR>
",$i);
if(!mysql_field_seek($result,$i))
{
print("Cannot seek to colum<BR>
");
continue;
}
$meta=mysql_fetch_field($result,$i);
if(!$meta)
{
print("No information available<BR>
");
continue;
}
print("<PRE>
");
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("</PRE>
");
}
?>
(17) string mysql_field_table(int result_id, int col_num);
返回結果集給定列的表名。對於計算列,此名為空。
col_num的范圍為0到mysql_num_fields()-1.
<?php
$link=mysql_pconnect("localhost","sunsoft","suixiang")
or die("Could not connect");
mysql_select_db("stamp_db");
$query="SELECT * FROM president";
$result=mysql_query($query) or die("Query failed");
for($i=0;$i<mysql_num_fields($result);$i++)
{
print("column $d:",$i);
printf("Name %s
",mysql_field_name($result,$i));
printf("Table %s
",mysql_field_nmae($result,$i));
print"<BR>
";
?>
(18) string mysql_field_type(int result_id, int col_num);
返回結果集給定列的類型名。類型名敬請等待參考本人的另外“MySQL列類型參考”。
col_num的范圍為0到mysql_num_fields()-1.
<?php
$link=pconnect("localhost","sunsoft","suixiang")
or die("Could not connect");
mysql_select_db("stamp_db");
$query="SELECT * FROM president";
$result=mysql_query($query) or die("Query failed");
for($i=0;$i<mysql_num_fields($result);$i++)
{
printf("colum %d:",$i);
printf("Name %s,
",mysql_field_name($result,$i));
printf("Type %s
",mysql_field_type($result,$i));
}
?>
(19) string mysql_field_flags(int result_id, int col_num);
作為字符串返回結果集中給定列的相關元數據信息,如果出現錯誤,則返回假。這個字符串由以空格分開的詞組成,說明哪個列的標記值為真。對於假的標記,在字符串中給出相應的詞。
col_num的范圍為0到mysql_num_fields()-1.
<?php
$link=mysql_pconnect("localhost","sunsoft","suixiang")
or die("Could not connect");
mysql_select_db("stamp_db");
$query="SELECT * FORM member";
$result=mysql_query($query) or die("Query failed");
for($i=0;$i<mysql_num_fields($result);$i++)
{
printf("column %d:",$i);
printf("Name %s,
",mysql_fields_name($result,$i));
printf("Flags %s
",mysql_fields_flags($result,$i));
}
?>
(20) int mysql_field_len(int result, int field_offset);
返回結果集給定列中值可能的最大長度。
col_num的范圍為0到mysql_num_fields()-1.
<?php
$link=mysql_pconnect("localhost","sunsoft","suixiang")
or die("Could not connect");
mysql_select_db("stamp_db");
$query="SELECT * FROM member";
$result=mysql_query($query) or die("Query failed");
for($i=0;$i<mysql_num_fields($result);$i++)
{
printf("Column %d:",$i);
printf("Name %s,
",mysql_field_name($result,$i));
printf("Len %d
",mysql_field_len($result,$i));
print"<BR>
";
}
?>