The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::Cookbook::Recipe::Searching::sql_lhs - SQL on the LHS of a comparison

DESCRIPTION

Output the results of the query

  SELECT * FROM payment 
  WHERE
    YEAR(payment_date) = 2006
    AND amount < 2.50

Sample Usage:

  shell> ${orm}_cmd sql_lhs  # orm = dbic, skinny, rose, etc

RECIPES

DBIx::Class

    package DBIx::Cookbook::DBIC::Command::sql_lhs;
    use Moose;
    extends qw(MooseX::App::Cmd::Command);
    
    
    sub execute {
      my ($self, $opt, $args) = @_;
    
    
      my $rs = do { 
    
        my $where = { 
                 'YEAR(payment_date)' => 2006,
                 amount => { '<' => 2.50 }
                };
        my $attr  = {};
    
        $self->app->schema->resultset('Payment')->search($where, $attr);
    
      };
    
      while (my $row = $rs->next) {
        use Data::Dumper;
        my %data = $row->get_columns;
        warn Dumper(\%data);
      }
    }
    
    1;