PHP 中的 mysqli fetch field direct函

首页 / PHP入门教程 / PHP 中的 mysqli fetch field direct函

mysqli fetch field direct - 语法

mysqli_fetch_field_direct(result,fieldIndex);

它用于将输出集中的下一列作为对象返回。

Sr.No 参数 & Description
1

result

它指定mysqli_query()、mysqli_store_result()或mysqli_use_result()返回的输出集标识符

2

fieldIndex

它指定字段索引,并且应该介于0和-1之间

无涯教程网

mysqli fetch field direct - 返回值

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

mysqli fetch field direct - 示例

<?php
   $connection_mysql=mysqli_connect("localhost","user","password","db");
   
   if (mysqli_connect_errno($connection_mysql)){
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   
   $sql="SELECT Lastname FROM Persons";
   
   if ($result=mysqli_query($connection_mysql,$sql)){
      $fieldinfo=mysqli_fetch_field_direct($result,1);
      
      print $fieldinfo->name;
      print $fieldinfo->table;
      print $fieldinfo->max_length;
      
      mysqli_free_result($result);
   }
   mysqli_close($connection_mysql);
?>

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

赵成的运维体系管理课 -〔赵成〕

软件测试52讲 -〔茹炳晟〕

iOS开发高手课 -〔戴铭〕

OAuth 2.0实战课 -〔王新栋〕

Selenium自动化测试实战 -〔郭宏志〕

陈天 · Rust 编程第一课 -〔陈天〕

大数据经典论文解读 -〔徐文浩〕

Serverless进阶实战课 -〔静远〕

高并发系统实战课 -〔徐长龙〕

好记忆不如烂笔头。留下您的足迹吧 :)