温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PHP mysqli_num_rows MySQLi 函数

发布时间:2020-08-05 21:36:56 来源:网络 阅读:592 作者:web全栈 栏目:web开发

定义和用法

mysqli_num_rows - 获取结果中的行数

版本支持

PHP4PHP5PHP7
不支持支持支持

语法

mysqli_num_rows ( mysqli_result $result )

返回结果集中的行数。 mysqli_num_rows的行为取决于是否使用缓冲的或未缓冲的结果集。 对于无缓冲的结果集,在检索到结果中的所有行之前,mysqli_num_rows不会返回正确的行数。

参数

参数必需的描述
result由 mysqli_query(),mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识。

返回值

返回结果集中的行数。如果行数大于PHP_INT_MAX,则该数字将作为字符串返回。

示例

$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($result = mysqli_query($link, "SELECT Code, Name FROM Country ORDER BY Name")) {
/* determine number of rows result set */
$row_cnt = mysqli_num_rows($result);
printf("Result set has %d rows.\n", $row_cnt);
/* close result set */
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);


相关函数

mysqli_query() - 对数据库执行一次查询

mysqli_affected_rows() - 获取上一个MySQL操作中受影响的行数

mysqli_store_result() - 转移上一次查询返回的结果集

mysqli_use_result() - 启动结果集检索


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI