您好!欢迎访问家园网-www.jy.wang!

家园网

php mysqli_fetch_array、mysqli_fetch_assoc、mysqli_fetch_row、mysqli_fetch_object 四个函数的区别

网络 作者:本站 点击:

1、mysqli_fetch_array() :使用或输出所有查询的数据

函数从结果集中取得一行作为数组【关联数组、数字数组、或者二者兼有】,如果没有更多行则返回false。

2、mysqli_fetch_assoc()和mysqli_fetch_row()都是把查询结果返回到一个数组中,都是返回第一行然后指针下移一行。

区别

assoc:用关键字索引取值

$row = $result->fetch_assoc();

echo $row[‘xx’];

mysqli_fetch_row()用数字索引取值


$row = $result->fetch_row();

echo $row[0];//注:“0”的意思是表中的第一个字段。

3、mysqli_fetch_object())将一行取回到一个对象中,然后通过类的方式取值

$row = $result->fetch_object();

echo $row->xx;


标签: