【发布时间】:2013-09-04 07:57:04
【问题描述】:
我一直在阅读 mysql_fetch_* 方法。 这是我从 PHP.org 网站了解到的。
mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_assoc — Fetch a result row as an associative array
mysql_fetch_object — Fetch a result row as an object
mysql_fetch_row — Get a result row as an enumerated array
看起来 mysql_fetch_array 包含了所有存在于
中的值mysql_fetch_assoc,mysql_fetch_object,mysql_fetch_row。因为mysql_fetch_assoc只包含关联数组,
mysql_fetch_row 包含数字数组中的数据。
mysql_fetch_object 也返回关联数组。
请告诉我我的理解是正确还是错误。
【问题讨论】:
-
您是正确的,除了 mysql_fetch_object 部分。 mysql_fetch_object 返回一个对象,其列名是该对象的属性。 mysql_fetch_array 没有这种类型的东西
-
是的,你基本上是在正确的轨道上。但请注意,所有
mysql_xxx()函数均已弃用,不建议使用;如果您正在学习 PHP,则应该学习更现代的 API,例如 PDO。