db2_field_name

(PECL ibm_db2 >= 1.0.0)

db2_field_name Returns the name of the column in the result set

说明

db2_field_name ( resource $stmt , mixed $column ) : string

Returns the name of the specified column in the result set.

参数

stmt

Specifies a statement resource containing a result set.

column

Specifies the column in the result set. This can either be an integer representing the 0-indexed position of the column, or a string containing the name of the column.

返回值

Returns a string containing the name of the specified column. If the specified column does not exist in the result set, db2_field_name() returns FALSE.

参见

User Contributed Notes

andryzulfikar at gmail dot com 28-Jun-2012 08:14
example:

<?php
// select all fields from salay table
$sql = "SELECT * FROM SALARY";

$stmt = db2_prepare($conn,$sql);

if(
db2_execute($stmt)){
   
$columns = db2_num_fields($stmt);
    for(
$i=0;$i<$columns;$i++){
       
$fieldName[] = db2_field_name($stmt,$i);
    }
   
print_r($fieldName);
}else{
    echo
db2_stmt_errormsg();
}

/* output
* Array ( [0] => ID [1] => USERID [2] => VALUE )
*/
?>