mysqli_fetch_lengths()

实例

返回结果集中的字段长度:

<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$sql="SELECT * FROM Persons ORDER BY Lastname";

if ($result=mysqli_query($con,$sql))
{
$row=mysqli_fetch_row($result);

// Display field lengths
foreach (mysqli_fetch_lengths($result) as $i=>$val)
{
printf("Field %2d has length: %2dn",$i+1,$val);
}

// Free result set
mysqli_free_result($result);
}

mysqli_close($con);
?>

定义和用法

mysqli_fetch_lengths() 函数返回结果集中的字段长度。


语法

mysqli_fetch_lengths(result);

参数 描述
result 必需。规定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符。

技术细节

返回值: 如果整数表示每个字段(列)的长度则返回数组,如果发生错误则返回 FALSE。
PHP 版本: 5+
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3