fetchOne vs. fetchAll vs. Sql's limit
| From: | AmirBehzad Eslami | Date: | Sun, 23 Oct 2011 05:52:34 +0000 |
| Subject: | fetchOne vs. fetchAll vs. Sql's limit | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-315395@lists.php.net to get a copy of this message | ||
Dear list,
As you already know, there are different ways to retrieve a record-set
from a database. For example, here's the classic way to perform this in PHP:
while ($row = mysql_fetch_assoc($db)) {
// my row is available here
}
Speacking about PHP internals, what exactly happens here?
1) The PHP asks the Database-Layer to give a record in each while pass?
I mean the record-set is not available in PHP's memory, but in MySQL's Mem.
2) Or the database-layer has gave the whole result-set to PHP, and we're
just fetching a single row from PHP's memory?
3) Finally, what is the efficient way to retrieve thousands or records which
need to be processed at once? Using LIMIT?
Kind regards,
-behzad