[Catalyst] looping

Michael Fuchs fox at fuechse.de
Mon Feb 12 20:30:45 GMT 2007


I think it's because you called search in list context. That way you end
up with an array of rows. Try it without the square brackets to get the
resultset.

mike


Will Smith schrieb:
> 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;
>         }
>
>  I get error:
> |Can't call method "next" without a package or object reference
>
> I know this is the error of declaration of the array and the method used to call, but did not see something similar in the docs.
>
> Thank you
> |
>
> ------------------------------------------------------------------------
> Looking for earth-friendly autos?
> Browse Top Cars by "Green Rating"
> <http://autos.yahoo.com/green_center/;_ylc=X3oDMTE4MGw4Z2hlBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW5jZW50ZXI->
> at Yahoo! Autos' Green Center.
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/
>   




More information about the Catalyst mailing list