[Catalyst] looping
Will Smith
willbelair at yahoo.com
Mon Feb 12 20:56:19 GMT 2007
thank you for your help. That's exactly what I want to do.
regards
Boris Æeraniæ <zextra at gmail.com> wrote: On 12/02/07, Will Smith wrote:
> Hi,
> I may ask the same old question, but just could get it. So please help me
> to get it done. All I want is looping through the record set for example: if
> I want to loop through a column, I can use this:
>
> my @lname;
> ########################
> my $column =
> $c->model("myDB::Author")->get_column('last_name');
> while(my $name = $column->next){
> $lname[$i] = $name;
> $i = $i + 1;
> }
> -----
> but if I try:
> my $recordset = [$c->model('myDB::Books')->search(
> authorid => "${authorid}" )];
> while(my $name = $recordset->next){
> $lname[$i] = $name->lname;
> $fname[$i] = $name->fname;
> $i = $i + 1;
> }
>...
>
> Thank you
>
You should have placed $recordset in foreach, like this:
my $recordset = [ something that returns list in list context ];
foreach my $name ( @$recordset ) {
...
}
_______________________________________________
List: Catalyst at lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/
---------------------------------
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070212/9f48183a/attachment.htm
More information about the Catalyst
mailing list