cubrid_field_type

(PECL CUBRID >= 8.3.0)
Return the type of the column corresponding to the given field offset
string cubrid_field_type ( resource $result, int $field_offset )

This function returns the type of the column corresponding to the given field offset. The returned field type could be one of the following: "int", "real", "string", etc.

Parameters:
result

Array type of the fetched result CUBRID_NUM, CUBRID_ASSOC, CUBRID_BOTH.

field_offset

The numerical field offset. The field_offset starts at 0. If field_offset does not exist, an error of level E_WARNING is also issued.

Returns:

Type of the column, on success.

FALSE when invalid field_offset value.

-1 if SQL sentence is not SELECT.

Examples:
cubrid_field_type() example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$result = cubrid_execute($conn"SELECT * FROM code");
 
$col_num = cubrid_num_cols($result);
 
printf("%-15s %-15s %s\n""Field Table""Field Name""Field Type");
for($i = 0; $i $col_num$i++) {
    printf("%-15s %-15s %s\n"
        cubrid_field_table($result$i), cubrid_field_name($result$i), cubrid_field_type($result$i)); 
}
 
cubrid_disconnect($conn);
?>

The above example will output:

Field Table     Field Name      Field Type
code            s_name          char
code            f_name          varchar
doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.