加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php mysqli_fetch_field_direct()函数

发布时间:2020-05-30 19:17:39 所属栏目:PHP 来源:互联网
导读:php mysqli_fetch_field_direct()函数将结果集中的单个列的元数据返回为对象。本文章向大家介绍mysqli_fetch_field_direct()函数的使用实例和基本使用方法,需要的朋友可以参考一下。

定义

mysqli_fetch_field_direct()函数将结果集中的单个列的元数据返回为对象。

语法

mysqli_fetch_field_direct(result,fieldIndex);

参数

参数

是必须的

描述

result

需要。

由mysqli_query(),mysqli_store_result()或mysqli_use_result()返回的结果集

fieldIndex

需要。

字段索引。必须是介于0和number_of_column - 1之间的整数

返回值

它返回一个包含字段定义信息的对象,如果失败则返回FALSE。

返回对象具有以下属性。

属性名称

含义

name

列的名称

orgname

原始列名称(如果使用别名)

table

表的名称

orgtable

原始表名(如果使用别名)

def

此字段的默认值

max_length

最大宽度

length

在表定义中指定的字段宽度

charsetnr

字段的字符集编号

flags

位标志

type

用于字段的数据类型

decimals

对于整数字段;使用的小数位数

实例

以下代码返回结果集中单个列的元数据,然后打印字段的名称,表和最大长度。

// http://www.manongjc.com/article/1661.html

// 作者:脚本之家教程

$con=mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno($con)){

echo "Failed to connect to MySQL: " . mysqli_connect_error();

}

$sql="SELECT Lastname FROM Persons";

if ($result=mysqli_query($con,$sql)){

// Get field information for "Age"

$fieldinfo=mysqli_fetch_field_direct($result,1);

print $fieldinfo->name;

print $fieldinfo->table;

print $fieldinfo->max_length;

mysqli_free_result($result);

}

mysqli_close($con);

?>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读