Firebird 2.0
PHP5 Programming
Manual

FBIRD_NUM_FIELDS

Purpose

Use the fbird_num_fields function to retrieve the number of columns in a result set.

Syntax

<num_fields> ::=
   fbird_num_fields( res_hndl )


Element 
Type
Description
res_hndl
resource
A valid result handle
<return>
mixed
Integer on success, False on failure

Semantics

The fbird_num_fields function returns an integer containing the number of fields in a result set. The function returns False upon failure.

Example

The below example code fragment queries for all columns of a table and prints the column information for each column in the result set:

$res = fbird_query("SELECT * FROM tablename");
$coln = fbird_num_fields($rs);
for ($i = 0; $i < $coln; $i++) {
$col_info = fbird_field_info($res, $i);
   echo "name: ". $col_info['name']. "\n";
   echo "alias: ". $col_info['alias']. "\n";
   echo "relation: ". $col_info['relation']. "\n";
   echo "length: ". $col_info['length']. "\n";
   echo "type: ". $col_info['type']. "\n";
}



See also

fbird_query, fbird_execute, fbird_field_info


previous page goto index next page

Legal information