Code Comments
Programming Forum and web based access to our favorite programming groups.You can use assign_by_ref() instead of plain old assign to use a reference, so you have one copy of the data instead of two. -bok On Fri, 30 Jul 2004 11:04:17 -0400, Travis Low <travis@dawnstar.com> wrote: > How does one handle very large result sets in Smarty? Normally, I try to page > DB results, but I have a client who wants to generate a very large page in the > browser. If I have to assign everything first, I run out of memory. Is t here > a way to use Smarty to pull the results from the db, or should I just writ e a > vanilla PHP page for that? > > cheers, > > Travis > > -- > Travis Low > <mailto:travis@dawnstar.com> > <http://www.dawnstar.com> > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Post Follow-up to this message> You can use assign_by_ref() instead of plain old assign to use a > reference, so you have one copy of the data instead of two. There should be no difference, unless either the original or the copy is subsequently changed (which is unlikely in a template variable). PHP maintains copied variables as references until their values diverge. -- Mark Rogers, More Solutions Ltd :: Tel: 0845 45 89 555
Post Follow-up to this messageOn Wed, Aug 04, 2004 at 05:35:04PM +0100, Mark Rogers wrote: > > There should be no difference, unless either the original or the copy is > subsequently changed (which is unlikely in a template variable). PHP > maintains copied variables as references until their values diverge. correct. but i think there is a caveat in php4 with foreach. the internal array pointer (http://php.net/current) is a property of the assigned array. if you do foreach($array as $item), the internal array-pointer gets reset. this is considered a change of the array and the whole thing gets copied. i didn't look for evidence of that in the php-source, but memory-consumption with foreach on large arrays makes me assume that. it would be great if anybody could confirm or rebut this. > -- > Mark Rogers, > More Solutions Ltd :: Tel: 0845 45 89 555 > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php
Post Follow-up to this message> > > You can use assign_by_ref() instead of plain old assign to use a > > correct. but i think there is a caveat in php4 with foreach. the > internal array pointer (http://php.net/current) is a property of the > assigned array. if you do foreach($array as $item), the internal > array-pointer gets reset. this is considered a change of the array and > the whole thing gets copied. > > i didn't look for evidence of that in the php-source, but > memory-consumption with foreach on large arrays makes me assume that. > > it would be great if anybody could confirm or rebut this. This is correct. See http://www.php.net/manual/en/contro...res.foreach.php for details. David
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.