PHP mysql_fetch_lengths() 함수

정의와 사용법

mysql_fetch_lengths() 함수는 각 필드의 내용 길이를 얻습니다.

이 함수들은 다음과 같은 행을 반환합니다:mysql_fetch_array()mysql_fetch_assoc()mysql_fetch_object() 또는 mysql_fetch_row()

성공하면, 이 함수는 숫자 배열을 반환하며, 오류가 발생하거나 다른 행이 없으면 false를 반환합니다.

문법

mysql_fetch_lengths(data)
매개변수 설명
data 필수. 사용할 데이터 포인터. 이 데이터 포인터는 mysql_query() 반환된 결과.

예제

<?php
$con = mysql_connect("localhost", "peter", "abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='Refsnes'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
print_r(mysql_fetch_lengths($result));
mysql_close($con);
?>

출력:

Array
(
[0] => Adams
[1] => John
[2] => London
)
Array
(
[0] => 5
[1] => 4
[2] => 6
)