On Tue, May 8, 2012 at 10:13 AM, Kenneth S Mclane <[email protected]>wrote:
> I am having a problem with my code and I cannot figure out why it is doing
> what it is doing. I have this sub:
>
> sub list :Local {
> my ($self, $c, $page) = @_;
> $page = $c->req->param('page') || 1;
> my $rs = $c->model('ORANGES::Account')->search({}, {
> join => 'progress',
> '+select' => ['progress.percent_complete'],
> '+as' => ['progress.percent_complete'],
> join => 'compliance',
> '+select' => ['compliance.percent_compliant'],
> '+as' => ['compliance.percent_compliant'],
> join => 'department_id',
> '+select' => ['department_id.department_id'],
> '+as' => ['department_id.department_id'],
> join => 'metrics',
> '+select' =>
> ['metrics.num_servers','metrics.num_subsystems'],
> '+as' => ['metrics.num_servers','metrics.num_subsystems'],
>
> order_by => 'account_code',
> rows => 15,
> page => $page,
> });
> $c->stash(accounts => $rs);
> $c->stash(pager => $rs->pager());
> $c->stash->{'template'}=>'accountview/list';
>
> }
I think this will solve the problem:
my $rs = $c->model('ORANGES::Account')->search({}, {
join => 'progress',
'+select' => ['progress.percent_complete'],
'+as' => ['progress.percent_complete'],
join => 'compliance',
'+select' => ['compliance.percent_compliant'],
'+as' => ['compliance.percent_compliant'],
join => 'department_id',
'+select' => ['department_id.department_id'],
'+as' => ['department_id.department_id'],
join => 'metrics',
'+select' =>
['metrics.num_servers','metrics.num_subsystems'],
'+as' => ['metrics.num_servers','metrics.num_subsystems'],
order_by => 'account_code',
rows => 15,
page => $page,
})*->first*;
I added the "->first" to the end. A result is more like a query. "->first"
tells DBIx to execute the query and return a row object of the first one.
--
Robert Wohlfarth
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/