For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > August 2004 > Re: [SMARTY] large result sets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] large result sets
Robert Amos

2004-07-30, 3:58 pm

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 there
> a way to use Smarty to pull the results from the db, or should I just write 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
>
>

Mark Rogers

2004-08-04, 4:02 pm

> 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
Messju Mohr

2004-08-04, 4:02 pm

On 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

David zülke

2004-08-04, 4:02 pm

> > > 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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com