PHP mysqli_fetch_field() 函数
PHP 教程
· 2019-01-27 21:13:31
返回结果集中下一字段(列),然后输出每个字段名称、表格和最大长度:
<?php
// 假定数据库用户名:root,密码:123456,数据库:CODERCTO
$con=mysqli_connect("localhost","root","123456","CODERCTO");
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
$sql="SELECT name,url FROM websites ORDER BY alexa";
if ($result=mysqli_query($con,$sql))
{
// 获取所有列的字段信息
while ($fieldinfo = mysqli_fetch_field($result)) {
printf("字段名: %s\n", $fieldinfo->name);
echo "<br>";
printf("数据表: %s\n", $fieldinfo->table);
echo "<br>";
printf("最大长度: %d\n", $fieldinfo->max_length);
echo "<br>";
}
// 释放结果集
mysqli_free_result($result);
}
mysqli_close($con);
?>
定义和用法
mysqli_fetch_field() 函数从结果集中取得下一字段(列),并作为对象返回。
语法
mysqli_fetch_field(result);
| 参数 | 描述 |
|---|---|
| result | 必需。规定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符。 |
技术细节
| 返回值: | 返回包含字段定义信息的对象。如果没有可用信息则返回 FALSE。该对象有下列属性:
|
|---|---|
| PHP 版本: | 5+ |
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
Open Data Structures
Pat Morin / AU Press / 2013-6 / USD 29.66
Offered as an introduction to the field of data structures and algorithms, Open Data Structures covers the implementation and analysis of data structures for sequences (lists), queues, priority queues......一起来看看 《Open Data Structures》 这本书的介绍吧!
CSS 压缩/解压工具
在线压缩/解压 CSS 代码
html转js在线工具
html转js在线工具