in reply to Querying data with and & or when using DBIx::Class
my $rs = $c->model("YOUset::THISupSOMEWHERE") ->search({ id => 1234, color => [qw/ Blue Orange /] }); # Same but different query form for conceptual reuse- $c->model("YOUset::THISupSOMEWHERE") ->search({ id => 1234, -or => [ color => "Blue", color => "Orange" ] });
DBIC in a Cat app is usually exposed as above. It sounds like you have not done any reading yet. DBIx::Class and Catalyst each have pretty big learning curves. You're gonna have to dig in and read and experiment if you want to really make use of their power. SQL::Abstract is the engine behind DBIC, so you can test it out without a DB or the schema classes–
use SQL::Abstract; my $sql = SQL::Abstract->new; { my ( $stmt, @bind ) = $sql ->select("Table", "*", { id => 1234, color => [qw/ Blue Orange /] }); print $stmt, $/; } { my ( $stmt, @bind ) = $sql ->select("Table", "*", { id => 1234, -or => [ color => "Blue", color => "Orange" ] }); print $stmt, $/; } __END__ SELECT * FROM Table WHERE ( ( ( color = ? OR color = ? ) AND id = ? ) +) SELECT * FROM Table WHERE ( ( ( color = ? OR color = ? ) AND id = ? ) +)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Querying data with and & or when using DBIx::Class
by phildeman (Scribe) on Sep 17, 2013 at 13:09 UTC | |
by Your Mother (Archbishop) on Sep 17, 2013 at 14:31 UTC | |
by phildeman (Scribe) on Sep 17, 2013 at 20:31 UTC | |
by Your Mother (Archbishop) on Sep 17, 2013 at 20:48 UTC | |
by phildeman (Scribe) on Sep 17, 2013 at 20:35 UTC |
In Section
Seekers of Perl Wisdom