Note that for some reason the length of fields is 3 times the actual value if you are using UTF8 encoding.. So a varchar(10) field returns 30 here. This renders this function almost useless.
mysql_field_len
(PHP 4, PHP 5)
mysql_field_len — 지정한 필드의 길이를 반환
설명
int mysql_field_len
( resource $result
, int $field_offset
)
mysql_field_len()은 지정 필드의 길이를 반환한다.
인수
- result
-
mysql_query() 호출을 통한 결과 resource.
- field_offset
-
The numerical field offset. The field_offset starts at 0. If field_offset does not exist, an error of level E_WARNING is also issued.
반환값
성공하면 지정 필드의 길이를, 실패하면 FALSE를 반환한다.
예제
Example #1 mysql_field_len() 예제
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
// 데이터베이스 스키마에 지정된
// id 필드의 길이를 얻습니다.
$length = mysql_field_len($result, 0);
echo $length;
?>
주의
Note:
하위 호환을 위하여, 다음의 권장하지 않는 별칭을 사용할 수 있습니다: mysql_fieldlen()
rvwoens at gmail dot com ¶
1 year ago
adam_nospam_hunger at yahoo dot com ¶
9 years ago
For a mysql type DECIMAL(8,4), the length is returned as 10 (M+2 as per documentation).
