note 40921 deleted from function.mysql-fetch-array by philip
| From: | philip@php.net | Date: | Fri, 25 Mar 2005 19:54:21 +0000 |
| Subject: | note 40921 deleted from function.mysql-fetch-array by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86989@lists.php.net to get a copy of this message | ||
Note Submitter: arjini at mac dot com
----
When designing any script that is going to be doing big queries, be aware that with large amounts of
data, this will cause headaches:
$query_result = mysql_query('sql statement');
for($i=0;$row=mysql_fetch_assoc($query_result);++$i)
$results[$i] = $row;
or something similar. If you pass $query_result around, you're just passing the resource, and
not the information itself. If one passes around $results with 10,000 items, you'll quickly be
out of memory.
Of course with tiny queries, it can be perfect (getting a user's info, or a single row out of
the db).
For generating HTML tables of query results, or dealing with massive data sets, I highly recommend
Vincent Oostindië's eclipse library:
http://www.students.cs.uu.nl/
people/voostind/eclipse/
index.php?page=download
Check out the QueryIterator and pagedQuery modules, you'll love them.