[Templates] Re: While loop iterator problem
[prev]
[thread]
[next]
[Date index for 2005/01/18]
On 18 Jan 2005, at 12:14, Jonathan Tweed wrote:
> Hello
>
> I am assigning a Class::DBI::Iterator as follows:
>
> my $years = OMAC::Event->search_archive_years();
>
> This method executes the following SQL statement:
>
> SELECT DISTINCT YEAR(start_date) AS year
> FROM __TABLE__
> WHERE end_date < CURRENT_DATE()
> ORDER BY year DESC
>
> I then pass this iterator into a template and try to use it as follows:
>
> [% WHILE (year = years.next) %]
>
> [% years.year %]
>
> [% END %]
>
> However, the loop never executes. There are two rows returned from the
> database.
>
> This works but is a bit messy and shouldn't be necessary!:
>
> [% WHILE i < years.count %]
>
> [% years.next.year %]
>
> [% i = i + 1 %]
>
> [% END %]
>
> It's worthing noting that I have successfully used the first syntax
> elsewhere in the same template but on a different iterator.
>
> Any ideas?
>
> Thanks
> Jon
Sorry to waste everyone's time. This is a Class::DBI issue. In case it
help anyone in the future, it's because the returned result set has no
primary key. The iterator is behaving correctly - as far as it is
concerned there are no results to return.
Jon
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
[Templates] Re: While loop iterator problem
Jonathan Tweed 15:19 on 18 Jan 2005
|