mysql_field_flags()
string mysql_field_flags(results,offset)
This function returns the field flags for a field of a
results set given. See mysql_fetch_field()
earlier in this chapter for a description of the flags. Specify the
desired field through the offset in the second argument. Here is an
example:
...
$sql_stmnt = "SELECT * FROM workreq LIMIT 1";
$results = mysql_query($sql_stmnt);
$num_fields = mysql_num_fields($results);
for ($index = 0; $index < $num_fields; $index++) {
$field_name = mysql_field_name($results, $index);
$flags = explode(' ', mysql_field_flags($results, $index));
print "$field_name \n";
print_r($flags);
print "\n\n";
}
...After retrieving one row as a sampler—using a
for statement and the number of fields in the
results set—this example determines the field name with
mysql_field_name() and the flags for each
field using mysql_field_flags(). The
mysql_field_flags() function assembles the
flags into an array in which the data is separated by spaces. By using
the explode() PHP function, you can retrieve
the elements of the array without having to know the number of
elements, and they are stored in $flags. Next,
print_r() displays the field name and prints
out the flags. Here is the output of the script for the first
field:
wrid
Array
(
[0] => not_null
[1] => primary_key
[2] => auto_increment
)