CUBRID 函数
PHP Manual

cubrid_num_fields

(PECL CUBRID >= 8.3.0)

cubrid_num_fieldsReturns the number of columns in the result set

说明

int cubrid_num_fields ( resource $result )

This function returns the number of columns in the result set, on success, or it returns FALSE on failure.

参数

result

result comes from a call to cubrid_execute()

返回值

Number of columns, on success.

-1 if SQL sentence is not SELECT.

范例

Example #1 cubrid_num_fields() example

<?php
    $link 
cubrid_connect("localhost"30000"demodb2""dba""");
    if (!
$link)
    {
        die(
'Could not connect.');
    }
    
$query 'SELECT id, name, address, salary FROM employees';
    
$result cubrid_execute($link$query);
    if (
$result
    {
        
$n cubrid_num_fields($result);
        echo 
"The resultset contains ".$n" fields: ";
        for (
$i 0$i $n$i++)
            echo 
cubrid_field_name($result$i)." ";
        
        
cubrid_close_request($result); 
    }
?>

以上例程会输出:

Result:
The resultset contains 4 fields: id name address salary

CUBRID 函数
PHP Manual