Home  >  Article  >  Database  >  mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?

mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?

WBOY
WBOYforward
2023-09-05 15:41:02606browse

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.

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete