mysql_fetch_row,mysql_fetch_array,mysql_fetch_object,mysql_fetch_assoc区别

1.mysql_fetch_row  只能以索引下标取值,从0开始。

2.mysql_fetch_array 能以索引下标取值,也可以用字段名称取值。

3.mysql_fetch_object 对象方式取值, ->

4.mysql_fetch_assoc 只能以字段名称取值。

补充一点:
mysql_fetch_array函数是这样定义的:array mysql_fetch_array ( resource result [,
int result_type]),返回根据从结果集取得的行生成的数组,如果没有更多行则返回 FALSE。
mysql_fetch_array()
中可选的第二个参数 result_type 是一个常量,可以接受以下值:MYSQL_ASSOC,MYSQL_NUM 和 MYSQL_BOTH。其中:

1、mysql_fetch_assoc($result)==mysql_fetch_array($result,MYSQL_ASSOC);

2、mysql_fetch_row($result)==mysql_fetch_array($result,MYSQL_NUM);

所以mysql_fetch_array()函数在某种程度上可以算是mysql_fetch_row()与
mysql_fetch_assoc()的集合。另外,mysql_fetch_array()另外还有MYSQL_BOTH参数,将得到一个同时包含关
联和数字索引的数组。

Link:http://www.jb51.net/article/17853.htm

原文地址:https://www.cnblogs.com/simpledev/p/3570153.html