Name
mysql_field_flags( )
Synopsis
mysql_field_flags(results
,offset
)
This returns
the field flags for a field of a results set given. See
mysql_fetch_field( )
for a description of the
flags. Specify the desired field through the offset in the second
argument.
... $sql_stmnt = "SELECT * FROM workreq LIMIT 1"; $results = mysql_db_query('workrequests', $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, the elements of
the array are retrieved without having to know the number of
elements, and they are stored in $flags
. Next, the
field name is displayed and the flags are printed out using
print_r( )
. Here is the output of the script for
the first field:
wrid Array ( [0] => not_null [1] => primary_key [2] => auto_increment )
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.