On Tue, May 14, 2002 at 11:36:00AM -0700, Scott Chapman wrote:
> > # If user is a member of acctmgr group, don't show them Status_Viewed records.
> > if ($group_file->ismember($req->{user},'acctmgr')) {
> > $db{'$where'} = $db{'$where'} . ' AND eventcode != ?';
> > $db{'$values'} = [$db{'$values'},'Status_Viewed'];
> > }
> >
> > # If the user is not a member of demomode,admin,developer don't show the
>Analyst_Activity records.
> > if ((!$group_file->ismember($req->{user}, 'demomode')) &&
> > (!$group_file->ismember($req->{user}, 'admin')) &&
> > (!$group_file->ismember($req->{user}, 'developer'))) {
> > $db{'$where'} = $db{'$where'} . ' AND eventcode != ?';
> > $db{'$values'} = [$db{'$values'},'Analyst_Activity'];
> > }
> >
> > *set = DBIx::Recordset -> Search(\%db);
> > $names = $set -> Names;
>
> This works fine if the two IF clauses fail. If both of the conditions are not met
>then the query works like it should. If either of the conditions is met, things
> break.
>
> The $values parameter is getting 'undef' in my DBI->Trace info:
>
> > -> bind_param for DBD::Sprite::st (DBI::st=HASH(0x85254e4)~0x883b6e4 1
>ARRAY(0x8a54604) undef)
> > -> bind_param for DBD::Sprite::st (DBI::st=HASH(0x85254e4)~0x883b6e4 2
>'Analyst_Activity' undef)
>
> ... so I think I'm specifying them incorrectly. I'm not familiar with
> the square brackets notation. I assume it makes an array? Clearly
> I'm missing something in my Perl knowlege. Can someone straighten me
> out?
The square brackets create a reference to an array. So when you use
$db{'$values'} inside your if statements you're getting the reference,
when what you're after is the array itself.
You can either dereference the arrayref by putting a @{} around it:
$db{'$values'} = [@{$db{'$values'}},'Analyst_Activity'];
or just use 'push' to append the item to the array:
push @{$db{'$values'}}, 'Analyst_Activity';
An equivalent style for this second one with your scalar $where would be:
$db{'$where'} .= ' AND eventcode != ?';
HTH.
Cheers,
Gavin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]