FBIRD_FIELD_INFO
Purpose
Use the fbird_filed_info function to retrieve
information about the columns of a result set.
Syntax
<field_info> ::= fbird_field_info(
res_hndl, col )
Element
|
Type
|
Description
|
res_hndl
|
resource
|
A valid result handle
|
col
|
integer
|
A column number (first column has number 0)
|
<return>
|
mixed
|
An array on success, false on failure
|
Semantics
The fbird_filed_info function returns an array
with information about a field after a select query has been run. The
array is in the form of name, alias, relation, length, type. If the
result handle is not valid, the function returns False.
On success this function returns an associative
array with five entries. Note that the entries have lowercase names.
Entry
|
Description
|
'name'
|
Name of the column. Typically an uppercase string
|
'alias'
|
Alias of the cooumn. Typically empty
|
'relation'
|
Name of the table or view that the column came from.
|
'length'
|
Length in bytes.
|
'type'
|
String with SQL type name.
|
The currently
supported type names are: CAHR, VARCHAR, SMALLINT, INTEGER, BIGINT,
FLOAT, DOUBLE PRECISION, TIMESTAMP, DATE, TIME, BLOB, ARRAY and QUAD.
Note that type names are in uppercase.
It is currently not
possible to retrieve further information about columns of type ARRAY,
such as type, dimensions, and lower and upper bounds. This may be
added in a later version of the Firebird PHP5 driver.
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_num_fields
|