maxdb_fetch_lengths

maxdb_result::lengths

(PECL maxdb >= 1.0)

maxdb_fetch_lengths -- maxdb_result::lengthsReturns the lengths of the columns of the current row in the result set

说明

过程化风格

maxdb_fetch_lengths ( resource $result ) : array

面向对象风格

array $maxdb_result->lengths;

The maxdb_fetch_lengths() function returns an array containing the lengths of every column of the current row within the result set represented by the result parameter. If successful, a numerically indexed array representing the lengths of each column is returned 或者在失败时返回 FALSE.

返回值

An array of integers representing the size of each column (not including any terminating null characters). FALSE if an error occurred.

maxdb_fetch_lengths() is valid only for the current row of the result set. It returns FALSE if you call it before calling maxdb_fetch_row/array/resource or after retrieving all rows in the result.

范例

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 * from hotel.customer WHERE cno = 3000";

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

   
$row $result->fetch_row();

   
/* display column lengths */
   
foreach ($result->lengths as $i => $val) {
       
printf("Field %2d has Length %2d\n"$i+1$val);
   }
   
$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 * from hotel.customer WHERE cno = 3000";

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

   
$row maxdb_fetch_row($result);

   
/* display column lengths */
   
foreach (maxdb_fetch_lengths($result) as $i => $val) {
       
printf("Field %2d has Length %2d\n"$i+1$val);
   }
   
maxdb_free_result($result);
}

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

以上例程的输出类似于:

Field  1 has Length  4
Field  2 has Length  3
Field  3 has Length  5
Field  4 has Length  6
Field  5 has Length  5
Field  6 has Length 21
相关文章
php ibm db2 函数 returns a result set listing the columns and associated privileges for a tablephp ibm db2 函数 returns a result set listing the columns and associated metadata for a tablephp ibm db2 函数 returns an array indexed by column position representing a row in a result setphp ibm db2 函数 returns an array indexed by column name representing a row in a result setphp ibm db2 函数 returns an array indexed by both column name and position representing a row in a result setphp ibm db2 函数 returns the width of the current value of the indicated column in a result setphp ibm db2 函数 returns a single column from a row in the result setphp ibm db2 函数 returns a result set listing the unique row identifier columns for a tablephp 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 函数 seeks to an arbitray row in statement result setphp maxdb 函数 returns result set metadata from a prepared statementphp mssql 函数 returns an associative array of the current row in the resultphp sqlite 函数 fetches a column from the current row of a result setphp sqlite 函数 fetches the current row from a result set as an arrayphp sqlite 函数 returns the number of fields in a result setphp mysqli result returns the current row of a result set as an objectphp mysqli result returns the lengths of the columns of the current row in the result set
关注编程学问公众号