Fetching Database Query Results
For most of the databases supported by PHP, you can get columns in two ways. You can specify a value by row number and column name, or you can fetch rows one at a time in an array. For MySQL this involves mysql_result and mysql_fetch_row, respectively.
Using mysql_result is much slower than the fetch functions. PHP has to work harder to find the exact piece of data you need. First, the specified row must be referenced. Then the data in that row must be searched for a column with a matching name. You can imagine that executing mysql_result several times inside a loop can add up to a very slow script. Each call has to start at the beginning and find the appropriate data element.
Alternatively, you may fetch an entire ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access