mysqli_fetch_lengths
    (PHP 5)
mysqli_fetch_lengths
    (no version information, might be only in CVS)
result->lengths -- 
     結果セットにおける現在の行のカラムの長さを返す
    
説明
手続き型:
array 
mysqli_fetch_lengths ( mysqli_result result )
オブジェクト指向型(プロパティ):
class 
mysqli_result { 
array lengths
}
     mysqli_fetch_lengths() 関数は、result
     が指す結果セットの現在の行について、すべてのカラムの長さを含む
     配列を返します。成功した場合、各カラムの長さを表す数値添字配列を
     返します。失敗した場合は FALSE を返します。
    
返り値
     各カラムのサイズ(終端の null 文字は含みません)を表す整数の配列を
     返します。エラー時には FALSE を返します。
    
     mysqli_fetch_lengths() は、結果セットの現在の行に
     ついてのみ有効です。mysqli_fetch_row/array/object をコールする前、あるいは
     結果のすべての行を取得した後にこの関数をコールすると、FALSE
     を返します。
    
例
| 例 1. オブジェクト指向型 | 
<?php$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
 
 /* 接続状況をチェックします */
 if (mysqli_connect_errno()) {
 printf("Connect failed: %s\n", mysqli_connect_error());
 exit();
 }
 
 $query = "SELECT * from Country ORDER BY Code LIMIT 1";
 
 if ($result = $mysqli->query($query)) {
 
 $row = $result->fetch_row();
 
 /* カラムの長さを表示します */
 foreach ($result->lengths as $i => $val) {
 printf("Field %2d has Length %2d\n", $i+1, $val);
 }
 $result->close();
 }
 
 /* 接続を閉じます */
 $mysqli->close();
 ?>
 | 
 | 
| 例 2. 手続き型 | 
<?php$link = mysqli_connect("localhost", "my_user", "my_password", "world");
 
 /* 接続状況をチェックします */
 if (mysqli_connect_errno()) {
 printf("Connect failed: %s\n", mysqli_connect_error());
 exit();
 }
 
 $query = "SELECT * from Country ORDER BY Code LIMIT 1";
 
 if ($result = mysqli_query($link, $query)) {
 
 $row = mysqli_fetch_row($result);
 
 /* カラムの長さを表示します */
 foreach (mysqli_fetch_lengths($result) as $i => $val) {
 printf("Field %2d has Length %2d\n", $i+1, $val);
 }
 mysqli_free_result($result);
 }
 
 /* 接続を閉じます */
 mysqli_close($link);
 ?>
 | 
 | 
上の例の出力は以下となります。
| Field  1 has Length  3
Field  2 has Length  5
Field  3 has Length 13
Field  4 has Length  9
Field  5 has Length  6
Field  6 has Length  1
Field  7 has Length  6
Field  8 has Length  4
Field  9 has Length  6
Field 10 has Length  6
Field 11 has Length  5
Field 12 has Length 44
Field 13 has Length  7
Field 14 has Length  3
Field 15 has Length  2 |