Gets field type.
string i5_field_type ( |
resource result/file, |
Fields types are different by nature in I5 and PHP environment. To known an I5 exact field type use i5_info function and fetch ASTYPE key value in the returned table.
i5_field_type function returns a character chain containing the type.
This value may be: "int", "bool", "float", "string" or "blob".
Note:
To know AS400 field type, call i5_info function and fetch "ASTYPE" key:
$info = i5_info($res, "CODE");
echo "Type AS CODE " . $info["ASTYPE"];
result |
Resource describing file or other record set .
|
field |
Integer or string identifying the field position or name.
|
Returns:
Field's type string.
I5_ERR_PHP_HDLDFT |
256 |
No default connection found. |
I5_ERR_PHP_OPTIONSTYPE |
259 |
The type of " I5_OPTIONS_ALIAS" option must be x and not x |
I5_ERR_PHP_OPTIONSNUMBER |
260 |
Option number -1 is unknown. |
I5_ERR_PHP_OPTIONSNUMBER |
260 |
Option number -1 is unknown. |
I5_ERR_PHP_TYPEPARAM |
262 |
Type of element x in parameter -1 must be y. Type z was provided. |
$result = i5_query("SELECT * FROM LATABLE");
$fields = i5_num_fields($result);
$lines = i5_num_rows($result);
echo "The table contains " . $fields . " columns and" . $lines . " line(s)\n";
echo "Columns are as follow:\n";
for ($i=0; $i < $fields; $i++) {
$type = i5_field_type($result, $i);
$name = i5_field_name($result, $i);
$len = i5_field_len($result, $i);
echo $type . " " . $name . " " . $len. "\n";
}