in reply to Re^3: Querying data with and & or when using DBIx::Class
in thread Querying data with and & or when using DBIx::Class
Thanks again for your response.
I am using MooseX.
The issue is resolved. Instead of building the WHERE clause in $whrcls, I simply added the complete DBIx::Class search within the if/else statement:
method get_colors( $id, $color1, $color2 ){
my @mycolor_objs;
if(!$color2){
@mycolor_objs = $schema->resultset( 'TblColors' )->search({ ID => $id, color => $color1 },
{ order_by => 'ID' });
}
else {
@myscolor_objs = $schema->resultset( 'TblColors' )->search({ ID => $id,
-or => [ color => $color1, color => $color2 ] },
{ order_by => 'ID' });
}
}
I am unsure at this moment, but it seems DBIx::Class is a little sensitive when using a scalar to represent the hash being passed as the WHERE clause. Thanks again. When I have a little more time, I will research building WHERE clauses with scalars.
I am using MooseX.
The issue is resolved. Instead of building the WHERE clause in $whrcls, I simply added the complete DBIx::Class search within the if/else statement:
method get_colors( $id, $color1, $color2 ){
my @mycolor_objs;
if(!$color2){
@mycolor_objs = $schema->resultset( 'TblColors' )->search({ ID => $id, color => $color1 },
{ order_by => 'ID' });
}
else {
@myscolor_objs = $schema->resultset( 'TblColors' )->search({ ID => $id,
-or => [ color => $color1, color => $color2 ] },
{ order_by => 'ID' });
}
}
I am unsure at this moment, but it seems DBIx::Class is a little sensitive when using a scalar to represent the hash being passed as the WHERE clause. Thanks again. When I have a little more time, I will research building WHERE clauses with scalars.
In Section
Seekers of Perl Wisdom