Today's Question:  Should we be worried about the win of AlphaGo?        GIVE A SHOUT

Technical Article => Web =>  PHP

mysql_fetch_array(),mysql_fetch_assoc() and mysql_fetch_row()

  Pi Ke      2011-08-05 04:53:09      6,335    0    0

In PHP MySQL mannual. There are three functions which need to be clarified for some users who may get confused when choosing which one to use to get the result.

mysql_fetch_array() : by seeting the different parameters, there are three ways to return the result set. MYSQL_ASSOC(Result set with field names as the associative indexs.It means you can use the field name as the index to get value of the specified cell). MYSQL_NUM(Result set with field names as the number indices). Or MYSQL_BOTH(you can use both modes to get value of a specified cell).

mysql_fetch_assoc():Result set with field names as the associative indexs.It means you can use the field name as the index to get value of the specified cell. It similars to mysql_fetch_array() with MYSQL_ASSOC speficied.

mysql_fetch_row():Result set with field names as the number indices.It similars to mysql_fetch_array() with MYSQL_NUM speficied.

Among these 3 functions, usually mysql_fetch_row() is the fastest one.

Note : mysql_fetch_object() has similar functions to the three functions mentioned above with the return value object instead of array.

PHP COMPARISON MYSQL RESULTSET MYSQL_FET

  SAVE AS PDF   MARK AS READ   MARK AS IMPORTANT

  RELATED


  0 COMMENT


No comment for this article.


  WRITE ARTICLE

When Bill Gates wants to buy a Lamborghini

By sonic0002