PreviousNext
Help > API Functions > Columns & parameters information > i5_field_type
i5_field_type

 

Gets field type.

 

         string i5_field_ type (resource result/file, int/string field)

 

 

Parameters

 

result

Resource describing file or other record set.

 

field

Integer or string identifying the field position or name.

 

 

Return

 

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.

 

 Details

 

         Fields types are different by nature in IBM i and PHP environment. To know an IBM i exact field type, use i5_info function and fetch ASTYPE key value in the returned table.

 

$info = i5_info($res, "CODE");

echo "Type AS CODE ". $info["ASTYPE"];

 

         i5_field_type function returns a character chain containing the type.

This value may be: "int", "bool", "float", "string" or "blob".

 

 

Example

 

                             $fields = i5_list_fields($file);

                             if (is_bool($fields))

                             {

                                             print_r("i5_list_fields error : ".i5_errormsg().'<br/>');

                             }

                             else

                             {

                                             $nb_fields = count($fields);

                                             echo "s_customer file contains ".$nb_fields." fields.<br/>";

            

                                             echo "Columns are as follow:<br/>";

                                             for ($i=0; $i < $nb_fields; $i++)

                                             {

                                                             $type = i5_field_type($file, $i);

                                                             $name  = i5_field_name($file, $i);

                                                             $len  = i5_field_len($file, $i);

                                                             if (is_bool($len))

                                                             {

                                                                            print_r("i5_field_len error : ".i5_errormsg().'<br/>');

                                                            }

                                                            echo $type . " " . $name . " " . $len. '<br/>';

                                             }

                             }

 

 

See also

 

i5_fied_name

i5_field_len

i5_field_scale

i5_info