David Schmidt <davew...@gmx.at> wrote on 06/13/2012 04:15:57 PM: > From: > > David Schmidt <davew...@gmx.at> > > To: > > The elegant MVC web framework <catalyst@lists.scsys.co.uk> > > Date: > > 06/13/2012 04:16 PM > > Subject: > > Re: [Catalyst] Can't get value from model > > Hi Kenneth, > > that's a DBIC question > > > anyways, what is the output of ... > > if ( $dept ) { > warn "REF: " . ref $dept . " DEPT_ID: " . $dept->department_id; > } else { > warn "No dept found"; > } > > ... after your query? > > On 13 June 2012 22:54, Kenneth S Mclane <ksmcl...@us.ibm.com> wrote: > > I am trying to get the value from a model call into a variable so I can use > > it for creating a DB record. I have tried multiple ways and cannot get the > > value to return. Here is my current attempt: > > > > my $dept = $c->model('ORANGES::Departments')->search_rs({'department_code' > > => $departmentcode}, { > > columns => ['department_id'] }); > > > > This returns "1". > > > > I tried this: > > > > my $dept = $c->model('ORANGES::Departments')->search_rs({'department_code' > > => $departmentcode}, { > > columns => ['department_id'] })->single; > > > > and got a hash reference. I know I am missing something very simple. If I > > was putting this into the stash I know I could access the value, but I am at > > a loss as to how to get to it inside my code. > > > > [error] Caught exception in dbms::Controller::Account->add "Can't locate object method "department_id" via package "DBIx::Class::ResultSet" at /home/ksmclane/catalyst/dbms/script/../lib/dbms/Controller/Account.pm line 49."
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/