| This article introduces the usage differences of mysql operation functions mysql_fetch_assoc (), mysql_fetch_array (), mysql_fetch_row (), and mysql_fetch_object () in php. For your reference. Similarities: all three functions return a row of data (that is, a row of data) queried in the database ). Difference: mysql_fetch_assoc () uses the key value (that is, the array subscript) of the corresponding field name in the database, for example, filed ['id'] = 1; Mysql_fetch_row () uses the automatically generated number (generated from 0 in turn) as the key value (that is, the array subscript), for example: filed [0] = 1; mysql_fetch_array () it uses the automatically generated number (generated from 0 in turn) as the key value (that is, the array subscript ), in addition, it also generates the corresponding field names in the database as the key value (that is, the array subscript ). For example, filed [0] = 1, filed ['id'] = 1; that is, mysql_fetch_array () integrates the results queried by mysql_fetch_assoc () and mysql_fetch_row. Mysql_fetch_object () is similar to mysql_fetch_assoc. Only the array returned by mysql_fetch_assoc. Mysql_fetch_object () returns the object. We hope that you will carefully understand the comparison and analysis above, so as to better understand their differences and specific application scenarios. |