
rbwohlfarth at gmail
May 8, 2012, 8:31 AM
Views: 385
Permalink
|
On Tue, May 8, 2012 at 10:13 AM, Kenneth S Mclane <ksmclane [at] us>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
|