What is the difference between mysql_fetch_object and mysql_fetch_array and mysql_fetch_assoc?

Posted on

MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array..

mysql_fetch_row-This function will return a row where the values will come in the order as they are defined in the SQL query, and the keys will span from 0 to one less than the number of columns selected.

mysql_fetch_assoc-This function will return a row as an associative array where the column names will be the keys storing corresponding value.

mysql_fetch_array-This function will actually return an array with both the contents of mysql_fetch_rowandmysql_fetch_assoc merged into one. It will both have numeric and string keys which will let you access your data in whatever way you’d find easiest.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s