Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: Querying data with and & or when using DBIx::Class

by phildeman (Acolyte)
on Sep 17, 2013 at 20:35 UTC ( #1054537=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^4: Querying data with and & or when using DBIx::Class

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054537]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-08-01 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (20 votes), past polls