[Catalyst] DBI search method problems

David Rio Deiros drio at console.net
Tue Feb 28 01:17:49 CET 2006


On Mon, Feb 27, 2006 at 04:07:01PM -0800, Mark Blythe wrote:
> It's only showing one because this line assigns only the first element
> of the returned array into $c->stash->{stations}:
> 
> >         ($c->stash->{stations}) =
> >             dbtest::Model::CDBI::Stationcontest->search(contest_id => $contest_id);
> 
> You should probably use the iterator if you want to access them all. 
> You start by assigning to a scalar, which returns an iterator object:
> 
> $c->stash->{stations} =
> dbtest::Model::CDBI::Stationcontest->search(contest_id =>
> $contest_id);
> 
> Then in your template, call next() on the iterator:
> 
> [% WHILE (s = stations.next) %]
>     [% s.call_letters %]
> [% END %]
> 
> ...or something very much like that

That was exactly what I was looking for. 

Thanks for your help guys,

David



More information about the Catalyst mailing list