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


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to