PHP mysql_field_flags() Funktion
Definition und Verwendung
Die Funktion mysql_field_flags() holt die mit dem angegebenen Feld verbundenen Marker aus dem Ergebnis.
Diese Funktion gibt das Feldsymbol des angegebenen Feldes zurück.
Wenn die MySQL-Version ausreichend neu ist, wird der folgende Marker unterstützt:
- auto_intcrement
- binary
- blob
- enum
- multiple_key
- not_null
- primary_key
- timestamp
- unique_key
- unsigned
- zerofill
Syntax
mysql_field_flags(data,field_offset)
Parameters | Description |
---|---|
data | Required. The data pointer to be used. This data pointer is from mysql_query() The returned result. |
field_offset | Required. Indicates from which field to return. 0 indicates the first field. |
Tips and Comments
Tip:Each flag is represented by a word, separated by a space, so you can use the explode() function to split the returned string into an array.
Example
<?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); ?>
Output:
not_null primary_key auto_increment