php 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); ?> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
