Home > Database > Mysql Tutorial > body text

mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?

WBOY
Release: 2023-09-05 15:41:02
forward
635 people have browsed it

mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?

These mysql_* functions are deprecated and other functions may be used to provide better security and functionality.

Note: As an alternative, you can use _assoc or _row.

mysql_fetch_assoc

This function returns an associative array of strings corresponding to the rows retrieved, or FALSE if there are no more rows. The associativity array tells us the key-value pairs, whereas the keys tell us any column names and the values ​​tell us the row values.

Here we can map column names to keys and values ​​to rows. For example.

Key is ID and value is corresponding name.
Copy after login

mysql_fetch_array

​​>

The name of this function indicates that it returns an array. It gets the result rows as an associative array, a numeric array, or both. Its keys have both numeric and string values.

mysql_fetch_object

This function returns rows as objects and does not return arrays.

The above is the detailed content of mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template