0

I'm learning php and mysql. When I read MySql from PHP-manual I realized that,
to return data from MySql in faster ways is in ordered.

mysql_fetch_array() > mysql_fetch_row() > mysql_fetch_assoc()

mysql_fetch_array() is faster than mysql_fetch_row() and mysql_fetch_assoc().
Can I missing something?
THANKS.......

Axeem
  • 670
  • 4
  • 16
  • 26
  • Congratulations! Are you asking why one is faster, how to use them, or what ? – adeneo May 28 '13 at 03:27
  • Each one return different format. – Jerin K Alexander May 28 '13 at 03:27
  • I only idinitify these. – Axeem May 28 '13 at 03:28
  • mysql_fetch_array is probably the fastest but by using it to large degree you are sacrificing code readability and maintainability for almost a negligible performance increase. if you are hitting a performance bottleneck then the problem is probably not what fetching mechanism you are using. – Orangepill May 28 '13 at 03:31

2 Answers2

1

Yes, you're missing the big red warning that says these functions are all deprecated and should not be used. Use mysqli or PDO instead.

In terms of performance, the real answer is: don't worry about it. The performance implications of accessing your MySQL data through objects or associative arrays is negligible. There are going to be much bigger performance issues in the way you write your queries and the rest of your software, and many of those aren't worth worrying about either.

See the classic PrematureOptimization article on c2.com.

Jonathan S.
  • 2,238
  • 16
  • 16
0

Regardless of performance, you shouldn't use these deprecated functions for a new project, look for the mysqli or PDO extensions.

Pier-Luc Gendreau
  • 13,553
  • 4
  • 58
  • 69