例
獲取所有字段字段信息,然後獲得與當前場mysqli_field_tell()並打印出每個列的名稱,表,最大長度:
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT Lastname,Age FROM Persons ORDER BY Lastname";
if ($result=mysqli_query($con,$sql))
{
// Get
field info for all fields
while
($fieldinfo=mysqli_fetch_field($result))
{
// Get field cursor position
$currentfield=mysqli_field_tell($result);
printf("Column %d:\n", $currentfield);
printf("Name:
%s\n", $fieldinfo->name);
printf("Table: %s\n",
$fieldinfo->table);
}
// Free result
set
mysqli_free_result($result);
}
mysqli_close($con);
?>
定義和用法
所述mysqli_field_tell()函數返回場光標的位置。
句法
mysqli_field_tell( result ) ;
參數 | 描述 |
---|---|
result | 需要。 指定由返回的結果集標識符mysqli_query() mysqli_store_result()或mysqli_use_result() |
技術細節
返回值: | 返回當前字段光標偏移 |
---|---|
PHP版本: | 5+ |
<PHP庫MySQLi參考