PHP 教程

PHP 7 新特性

PHP mysqli_field_count() 函数

PHP MySQLi 参考手册 PHP MySQLi 参考手册

实例

假设我们有一个 "Friends" 表,其中有 3 个字段 20 行记录。返回最近查询的列数:

<?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();
 }

mysqli_query($con,"SELECT * FROM Friends");
// Get number of columns - will always return 3
mysqli_field_count($con);

mysqli_close($con);
 ?>

定义和用法

mysqli_field_count() 函数返回最近查询的列数。

语法

mysqli_field_count(connection);
参数描述
connection必需。规定要使用的 MySQL 连接。

技术细节

返回值:返回一个表示结果集中列数的整数。
PHP 版本:5+

PHP MySQLi 参考手册 PHP MySQLi 参考手册

新闻动态 联系方式 广告合作 招聘英才 安科实验室 帮助与反馈 About Us

Copyright © 2013 - 2019 Ancii.com All Rights Reserved京ICP备18063983号-5 京公网安备11010802014868号