PHP mysql_field_flags() function
Definition and usage
The mysql_field_flags() function retrieves the flags associated with the specified field from the result.
This function returns the field flags of the specified field.
If the MySQL version is sufficiently new, it will support the following flags:
- 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 use. The data pointer is from mysql_query() The returned result. |
field_offset | Required. Indicates from which field to start returning. 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