This section focuses on the 4 functions that get a query result set, which are compared in a comprehensive comparison.
Mysql_result (): The advantage is ease of use, and the disadvantage is that the function is small, one call can only get a row of records in the result data set, the larger database is less efficient. Mysql_result ($result, line number, column number) line number and column number are counted starting from 0
Mysql_fetch_row (): The advantage is that the efficiency of execution is the highest in 4 methods; The disadvantage is that you can only use numbers as attribute indexes to get property values, which is very confusing when used.
MYSQL_FETCH_ASSOC (): The property value can only be obtained key=>value form with the property name.
Mysql_fetch_array (): The execution efficiency is also very high, similar to Mysql_fetch_row (), and can be directly obtained by the attribute Name property values, so in practical applications, is the equivalent of Mysql_num_row () and MySQL The combination of _FETCH_ASSOC ().
Mysql_fetch_object (): The use of object-oriented thinking, in the design of ideas more advanced, if the reader is accustomed to object-oriented thinking to write programs, it will be natural to choose it. Second, the advantages of this method are also reflected in the more complex structure of the data results, logic is more clear.
The common denominator of the next 4 functions is to get the data for the current row and then automatically slide back one line. Sometimes, you want to control the number of rows to slide, which is often used with a function that is Mysql_data_seek (), which is defined as:
int mysql_data_seek (int result_identifier,int row_number)
Call this function to slide the row_number row backwards in the result set, and the next time the mysql_fetch_* function is called, the record after the Row_number row is read backwards.
Php-mysql result set function comparison