[Dbix-class] Complex query in custom resultsource file.

Jonathan Rockway jon at jrock.us
Tue Feb 12 07:01:00 GMT 2008


* On Tue, Feb 12 2008, edwrb . wrote:
> Thanks Matt.  That 'as' trick took care of the SQL parsing issue.
>
> On a related note, is there a best practice for iterating through the
> result-set from these
> custom resource files by chance?  I thought something like the following would
> work:
>
>   my $rs = [ $schema->resultset( 'MainRecordQuery' )->search( {},
>     {
>       bind  => [ $category, 'Y', 'thumbnail', 'main']
>     }
>   ) ];
>
> while (my $data = $rs->next) {
>
>     print $data->thumbnail . "\n";
> }
>
> but it fails with the following error:
>
> 'Can't call method "next" on unblessed reference'  (from the while loop)

Well yeah, you've made $rs an array.  Omit the square brackets if you
want a resultset instead of a reference to a list of row objects.

Regards,
Jonathan Rockway



More information about the DBIx-Class mailing list