Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users
Re: Getting hashref instead of value
 

Index | Next | Previous | View Flat


rbwohlfarth at gmail

May 8, 2012, 8:31 AM


Views: 385
Permalink
Re: Getting hashref instead of value [In reply to]

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

Subject User Time
Getting hashref instead of value ksmclane at us May 8, 2012, 8:13 AM
    Re: Getting hashref instead of value billcrawford1970 at gmail May 8, 2012, 8:24 AM
    Re: Getting hashref instead of value ari.constancio at gmail May 8, 2012, 8:25 AM
    Re: Getting hashref instead of value steve at matsch May 8, 2012, 8:25 AM
        Re: Getting hashref instead of value fs5 at sanger May 8, 2012, 8:31 AM
            Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:46 AM
    Re: Getting hashref instead of value rbwohlfarth at gmail May 8, 2012, 8:31 AM
    Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:33 AM
    Re: Getting hashref instead of value alexander.hartmaier at t-systems May 8, 2012, 8:33 AM
        Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:44 AM
    Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:37 AM
    Re: Getting hashref instead of value billcrawford1970 at gmail May 8, 2012, 8:48 AM
    Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:54 AM
    Re: Getting hashref instead of value billcrawford1970 at gmail May 8, 2012, 8:59 AM
    Re: Getting hashref instead of value fs5 at sanger May 8, 2012, 9:03 AM
    Re: Getting hashref instead of value alexander.hartmaier at t-systems May 8, 2012, 9:05 AM
        Re: Getting hashref instead of value ksmclane at us May 8, 2012, 9:15 AM
        Re: Getting hashref instead of value ksmclane at us May 8, 2012, 9:25 AM
    Re: Getting hashref instead of value alexander.hartmaier at t-systems May 8, 2012, 9:23 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.