mysql_field_name到新的mysqli [英] mysql_field_name to the new mysqli

查看:53
本文介绍了mysql_field_name到新的mysqli的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种方法来获取表中各列的名称.它工作正常,但现在我想更新到新的mysqli吗? (我尝试了mysqli_fetch_field,但是我不知道如何适用于这种情况,我不确定这是否是wright选项)

I have a way to get the name of the columns of a table. It works fine but now I want to update to the new mysqli ? (I tried the mysqli_fetch_field but I don't know how to apply to this case and I am not sure if it is the wright option)

如何使用mysqli进行相同操作? :

How to do the same with mysqli ? :

$sql = "SELECT * from myTable";
$result = mysql_query($sql,$con);
$id = mysql_field_name($result, 0);
$a = mysql_field_name($result, 1);

echo $id;
echo $a;

推荐答案

我不确定是否有更好的方法可以做到这一点,但是我检查了它是否可以获取列名,并且是新的mysqli:

I'm not sure if there is a better way to do that, but I checked that this works to get just the name of the columns and is the new mysqli :

$result = mysqli_query($con, 'SELECT * FROM myTable');
while ($property = mysqli_fetch_field($result)) {
    echo $property->name;
}

这篇关于mysql_field_name到新的mysqli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆