note 68761 added to function.mysql-fetch-array

From: Date: Wed, 09 Aug 2006 21:00:10 +0000
Subject: note 68761 added to function.mysql-fetch-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-115738@lists.php.net to get a copy of this message
Does anyone know how clever PHP is at memory handeling? "Performance: An important thing to note is that using mysql_fetch_array() is not significantly slower than using mysql_fetch_row(), while it provides a significant added value." In a loop such as this: <?php while($Row = mysql_fetch_array($ResID)) { // Do some stuff } ?> The memory needed for the field names should be freed each time the $Row gets re-assigned. However in a loop such as this: <?php $i = 0; $Row = array(); while($Row[$i] = mysql_fetch_array($ResID)) { $i++ } ?> Where the field names are stored in each $Row[$i]. Is the field names just assigned a reference (or pointer, if you wish) to the actual field name? Or does each $Row[$i] contain a copy of all the field names? In Delphi they call it "copy on demand", when multiple seeming unique blocks of memory share memory as long as they are all the same. So, does PHP do this? And if so, I assume it is ok to fetch thousands of rows with their fieldnames and keep them all in memory at once? ---- Server IP: 129.16.214.50 Probable Submitter: 213.66.117.10 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php Edit -- https://master.php.net/note/edit/68761 Del: integrated -- https://master.php.net/note/delete/68761/integrated Del: useless -- https://master.php.net/note/delete/68761/useless Del: bad code -- https://master.php.net/note/delete/68761/bad+code Del: spam -- https://master.php.net/note/delete/68761/spam Del: non-english -- https://master.php.net/note/delete/68761/non-english Del: in docs -- https://master.php.net/note/delete/68761/in+docs Del: other reasons-- https://master.php.net/note/delete/68761 Reject -- https://master.php.net/note/reject/68761 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115738) next »