downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_fetch_object> <mysql_fetch_field
[edit] Last updated: Fri, 25 May 2012

view this page in

mysql_fetch_lengths

(PHP 4, PHP 5)

mysql_fetch_lengths結果における各出力の長さを得る

説明

array mysql_fetch_lengths ( resource $result )

MySQL により一番最近に取得された行における各フィールドの長さを 格納した配列を返します。

mysql_fetch_lengths()は、 mysql_fetch_row(), mysql_fetch_assoc(), mysql_fetch_array(), そして mysql_fetch_object() により一番最近に返された 各結果カラムの長さを格納した配列を返します。この配列のオフセットは 0 から始まります。

パラメータ

result

評価された結果 リソース。 この結果は、mysql_query() のコールにより得られたものです。

返り値

成功した場合に長さの配列(array)を、 失敗した場合に FALSE を返します。

例1 mysql_fetch_lengths() の例

<?php
$result 
mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!
$result) {
    echo 
'Could not run query: ' mysql_error();
    exit;
}
$row     mysql_fetch_assoc($result);
$lengths mysql_fetch_lengths($result);

print_r($row);
print_r($lengths);
?>

上の例の出力は、 たとえば以下のようになります。

Array
(
    [id] => 42
    [email] => user@example.com
)
Array
(
    [0] => 2
    [1] => 16
)

参考



add a note add a note User Contributed Notes mysql_fetch_lengths
Bavo Janss 10-Jul-2009 01:19
In case of UTF8 fields mysql_field_len() will return 3 times the maximum length (e.g. 30 for a VARCHAR(10) field)) for mysql_field_len() returns the byte length of the field not the defined size.
09-Feb-2006 11:23
For the maximum length of a field (e.g. 10 for a VARCHAR(10) field), use mysql_field_len().

 
show source | credits | stats | sitemap | contact | advertising | mirror sites