PHP mysql_field_flags() 函數(shù)
定義和用法
mysql_field_flags() 函數(shù)從結(jié)果中取得和指定字段關(guān)聯(lián)的標(biāo)志。
本函數(shù)返回指定字段的字段標(biāo)志。
如果 MySQL 版本足夠新,則會(huì)支持以下的標(biāo)志:
- auto_intcrement
- binary
- blob
- enum
- multiple_key
- not_null
- primary_key
- timestamp
- unique_key
- unsigned
- zerofill
語(yǔ)法
mysql_field_flags(data,field_offset)
參數(shù) | 描述 |
---|---|
data | 必需。要使用的數(shù)據(jù)指針。該數(shù)據(jù)指針是從 mysql_query() 返回的結(jié)果。 |
field_offset | 必需。指示從哪個(gè)字段開(kāi)始返回。0 指示第一個(gè)字段。 |
提示和注釋
提示:每個(gè)標(biāo)志都用一個(gè)單詞表示,之間用一個(gè)空格分開(kāi),因此,您可以通過(guò) explode() 函數(shù)把返回的字符串打散到一個(gè)數(shù)組中。
例子
<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person";
$result = mysql_query($sql,$con);
$flags = mysql_field_flags($result, 0)
;
echo $flags;
mysql_close($con);
?>
輸出:
not_null primary_key auto_increment