Hi Sam,

Remember you are only dealing with an array of references. Not the
actual record. This shouldn't take much time to do a copy and you will
only be keeping pointers in memory not much else.

Regards


David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia

+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax


-----Original Message-----
From: sam wun [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 6 January 2005 1:53 PM
Cc: mysql
Subject: Re: traverse the recordset more than once

Steve Buehler wrote:

> At 08:11 PM 1/5/2005, you wrote:
>
>> Hi list,
>>
>> How can I traverse the recordset moret than once?
>>
>> For example, the recordset $sth is returned from executing the sql 
>> statement.
>> The following statement is writen with the "for" loop for retrieving 
>> each record from the recordset.
>>
>> $aref = $sth->fetchrow_arrayref
>>
>> However when the "for" loop is finished, the pointer of the recordset

>> is point to the end of the recordset. How can I revise the point to 
>> the beginning of the recordset ($sth)?
>
>
> Another thing you might try is to Set
> $arefgood = $sth->fetchrow_arrayref
> $arefusethisone = $arefgood
> Use the $arefusethisone in the for loop.  When you want to restart the

> for loop, just set "$arefusethisone = $arefgood" again.  Doing this, 
> you should always have your original.  This will probably work in any 
> language you are programming in, but since I don't program in to many 
> languages, I can't give you a definite on that one.
>
Thanks I hvae thought about this method, but conerning that it  will 
require extra memory to keep the orginal copy of the recordset, and also

whenever assign the original recordset to the temprecordset, it will 
need to take extra time to do the copies, I assumed this is not shadow 
copies.

Sam

> Steve
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to