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 [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to