mysql_field_len
(PHP 4, PHP 5, PECL mysql:1.0)
mysql_field_len — Returns the length of the specified field
說明
int mysql_field_len
( resource $result
, int $field_offset
)
mysql_field_len() returns the length of the specified field.
參數
- result
-
回傳類型為 resource 的結果集。該結果集從 mysql_query() 的呼叫中得到。
- field_offset
-
數字形式的欄位偏移量。field_offset 開始於 0。如果 field_offset 不存在,系統會發出 E_WARNING 級別的警告信息。
Return值
The length of the specified field index on success, or FALSE on failure.
範例
Example#1 mysql_field_len() example
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
// Will get the length of the id field as specified in the database
// schema.
$length = mysql_field_len($result, 0);
echo $length;
?>
註釋
Note: 為了保證向下相容性,可以使用下面的別名,但不贊成使用它: mysql_fieldlen()