maxdb_fetch_field

maxdb_result::fetch_field

(PECL maxdb >= 1.0)

maxdb_fetch_field -- maxdb_result::fetch_fieldReturns the next field in the result set

说明

过程化风格

maxdb_fetch_field ( resource $result ) : mixed

面向对象风格

maxdb_result::fetch_field ( void ) : mixed

The maxdb_fetch_field() returns the definition of one column of a result set as an resource. Call this function repeatedly to retrieve information about all columns in the result set. maxdb_fetch_field() returns FALSE when no more fields are left.

返回值

Returns an resource which contains field definition information or FALSE if no field information is available.

Object properties
Property Description
name The name of the column
max_length The maximum width of the field for the result set.
type The data type used for this field
decimals The number of decimals used (for integer fields)

范例

Example #1 面向对象风格

<?php
$maxdb 
= new maxdb("localhost""MONA""RED""DEMODB");

/* check connection */
if (maxdb_connect_errno()) {
   
printf("Connect failed: %s\n"maxdb_connect_error());
   exit();
}

$query "SELECT name, cno from hotel.customer ORDER BY cno";

if (
$result $maxdb->query($query)) {

   
/* Get field information for all columns */
   
while ($finfo $result->fetch_field()) {

       
printf("Name:     %s\n"$finfo->name);
       
printf("Table:    %s\n"$finfo->table);
       
printf("max. Len: %d\n"$finfo->max_length);
       
printf("Flags:    %d\n"$finfo->flags);
       
printf("Type:     %d\n\n"$finfo->type);
   }
   
$result->close();
}

/* close connection */
$maxdb->close();
?>

Example #2 过程化风格

<?php
$link 
maxdb_connect("localhost""MONA""RED""DEMODB");

/* check connection */
if (maxdb_connect_errno()) {
   
printf("Connect failed: %s\n"maxdb_connect_error());
   exit();
}

$query "SELECT name, cno from hotel.customer ORDER BY cno";

if (
$result maxdb_query($link$query)) {

   
/* Get field information for all fields */
   
while ($finfo maxdb_fetch_field($result)) {

       
printf("Name:     %s\n"$finfo->name);
       
printf("Table:    %s\n"$finfo->table);
       
printf("max. Len: %d\n"$finfo->max_length);
       
printf("Flags:    %d\n"$finfo->flags);
       
printf("Type:     %d\n\n"$finfo->type);
   }
   
maxdb_free_result($result);
}

/* close connection */
maxdb_close($link);
?>

以上例程的输出类似于:

Name:     NAME
Table:
max. Len: 10
Flags:    -1
Type:     2

Name:     CNO
Table:
max. Len: 4
Flags:    -1
Type:     0

参见

相关文章
php ibm db2 函数 returns a result set listing the columns and associated privileges for a tablephp ibm db2 函数 sets the result set pointer to the next row or requested rowphp ibm db2 函数 returns the name of the column in the result setphp ibm db2 函数 returns the number of fields contained in a result setphp ibm db2 函数 returns a result set listing the tables and associated privileges in a databasephp ibm db2 函数 returns a result set listing the tables and associated metadata in a databasephp maxdb 函数 returns the default character set for the database connectionphp maxdb 函数 returns the next field in the result setphp maxdb 函数 returns an array of resources representing the fields in a result setphp maxdb 函数 returns the lengths of the columns of the current row in the result setphp maxdb 函数 returns the current row of a result set as an objectphp maxdb 函数 set result pointer to a specified field offsetphp maxdb 函数 get current field offset of a result pointerphp maxdb 函数 prepare next result from multi queryphp maxdb 函数 returns result set metadata from a prepared statementphp maxdb 函数 initiate a result set retrievalphp oci8 函数 returns the next child statement resource from a parent statement resource that has oracle database 12c implicit result setsphp sqlsrv 函数 retrieves the next row of data in a result set as an objectphp sqlsrv 函数 makes the next row in a result set available for readingphp mysqli result returns the next field in the result set
关注编程学问公众号