Php/docs/function.fbsql-fetch-field

From Get docs

fbsql_fetch_field

(PHP 4 >= 4.0.6, PHP 5 < 5.3.0)

fbsql_fetch_fieldGet column information from a result and return as an object


Description

fbsql_fetch_field ( resource $result [, int $field_offset ] ) : object

Used in order to obtain information about fields in a certain query result.


Parameters

result
A result identifier returned by fbsql_query() or fbsql_db_query().
field_offset
The numerical offset of the field. The field index starts at 0. If not specified, the next field that wasn't yet retrieved by fbsql_fetch_field() is retrieved.


Return Values

Returns an object containing field information, or FALSE on errors.

The properties of the object are:

  • name - column name
  • table - name of the table the column belongs to
  • max_length - maximum length of the column
  • not_null - 1 if the column cannot be NULL
  • type - the type of the column


Examples

Example #1 fbsql_fetch_field() example

<?phpfbsql_connect($host, $user, $password)    or die("Could not connect");$result = fbsql_db_query("database", "select * from table")    or die("Query failed");# get column metadata$i = 0;while ($i < fbsql_num_fields($result)) {    echo "Information for column $i:<br />\n";    $meta = fbsql_fetch_field($result);    if (!$meta) {        echo "No information available<br />\n";    }    echo "<pre>max_length:   $meta->max_lengthname:         $meta->namenot_null:     $meta->not_nulltable:        $meta->tabletype:         $meta->type</pre>";    $i++;}fbsql_free_result($result);?>

See Also