mysql_fetch_array和mysql_fetch_row之间的区别? [英] Difference between mysql_fetch_array and mysql_fetch_row?

查看:86
本文介绍了mysql_fetch_array和mysql_fetch_row之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于PHP用户,这是一个简单的问题.我无法在PHP中得到mysql_fetch_array()mysql_fetch_row()的确切区别的原因是我一直在使用Java.

This is a simple question for PHP users. The reason I couldn't get the the exact difference between mysql_fetch_array() and mysql_fetch_row() in PHP is that I had been working much with Java.

在我将这个问题发布到这里之前,我从Google那里得到了一些答案,但是我发现它们有些令人困惑.我在互联网上找到的一些链接如下.

Before I post this question here, I got some answers from Google but I found they're somewhat confusing. Some of the links I found on the internet are as follows.

答案1

答案2

答案3

答案4

我无法从上述答案中得到确切的想法.那么实际上它们之间的确切区别是什么?

I couldn't get the exact idea from the above answers. So actually what is the exact difference between them?

推荐答案

文档对此很清楚,您看过吗?

The documentation is pretty clear on this, have you looked at it ?

mysql_fetch_array ( resource $result [, int $result_type = MYSQL_BOTH ] )

返回与提取的行相对应的字符串数组,或者 如果没有更多行,则为FALSE. 返回数组的类型取决于 如何定义result_type.通过使用MYSQL_BOTH(默认),您将获得 具有关联索引和数字索引的数组.使用MYSQL_ASSOC, 您仅获得关联索引(当mysql_fetch_assoc()起作用时), [by]使用 MYSQL_NUM,您只会得到数字索引(因为mysql_fetch_row()有效).

Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. The type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), [by] using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).

mysql_fetch_row ( resource $result )

返回与获取的字符串相对应的数字数组 行,如果没有更多行,则为FALSE.

Returns an numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows.

mysql_fetch_row()从关联的结果中获取一行数据 具有指定的结果标识符. 该行以数组形式返回. 每个结果列都存储在数组偏移量中,从偏移量0开始.

mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

总结

mysql_fetch_array( $result, MYSQL_ASSOC ) = mysql_fetch_assoc( $result ) mysql_fetch_array( $result, MYSQL_NUM ) = mysql_fetch_row( $result )

还有

mysql_fetch_array ( $result ) = mysql_fetch_assoc( $result ) + mysql_fetch_row( $result )

这篇关于mysql_fetch_array和mysql_fetch_row之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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