[Dbix-class] problem accessing stored procedure

Jess Robinson castaway at desert-island.demon.co.uk
Mon Oct 30 10:10:32 GMT 2006



On Mon, 30 Oct 2006, Devin Austin wrote:

> hey everyone,
>
> I'm attempting to select the userid and count(*) from my Users table
> where username=$q->param('username')
> and password=$q->param('password'), using the following code:
>
> my $user = $schema->resultset('User')->single(
>>        {
>>            username => $q->param('username'),
>>            password => $q->param('password')
>>        },
>>        {
>>          select => [
>>            'userid', {  count => '*' }
>> ] ,
>>          as => [qw/userid is_authorized/],
>>        }
>> ) ;
>>
>>      my $userid = $user->userid;
>>      my $authenticated = $user->is_authorized eq '1' ? 1 : 0;
>
>
> I'm getting this error:
>
>>  "Can't locate object method "is_authorized" via package "Notes::DBI::User"
>>  at Notes.pm line 323"
>

Yup, you're missing the part of the AS docs which says:

If there's already an accessor with the name given in the as list, it will 
be used, otherwise you'll need to use get_column('is_authorised') instead.

Or words to that effect. If there's no "is_authorized" column already, you 
can only access it using get_column.

Jess




More information about the DBIx-Class mailing list