RE: [SMARTY] large result sets
| From: | David Zülke | Date: | Wed, 04 Aug 2004 17:13:16 +0000 |
| Subject: | RE: [SMARTY] large result sets | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11664@lists.php.net to get a copy of 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.
>
> 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/control-structures.foreach.php
for details.
David