cvs commit: p5ee/App-Repository/lib/App/Repository DBI.pm

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     05/10/12 06:59:36

  Modified:    App-Repository/lib/App/Repository DBI.pm
  Log:
  added the _do() method so you won't do $db->{dbh}->do() or $db->{dbh}->selectall_arrayref()
  
  Revision  Changes    Path
  1.28      +32 -2     p5ee/App-Repository/lib/App/Repository/DBI.pm
  
  Index: DBI.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/lib/App/Repository/DBI.pm,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- DBI.pm	9 Aug 2005 18:52:25 -0000	1.27
  +++ DBI.pm	12 Oct 2005 13:59:36 -0000	1.28
  @@ -2053,6 +2053,36 @@
       $retval;
   }
   
  +sub _do {
  +    &App::sub_entry if ($App::trace);
  +    my ($self, $sql) = @_;
  +    $self->{error} = "";
  +    $self->{sql} = $sql;
  +    my $dbh = $self->{dbh};
  +    my $retval = 0;
  +
  +    my $debug_sql = $self->{context}{options}{debug_sql};
  +    if ($debug_sql) {
  +        print "DEBUG_SQL: _do()\n";
  +        print $sql;
  +    }
  +    if (defined $dbh) {
  +        if ($sql =~ /^select/i) {
  +            $retval = $dbh->selectall_arrayref($sql);
  +        }
  +        else {
  +            $retval = $dbh->do($sql);
  +        }
  +    }
  +    if ($debug_sql) {
  +        print "DEBUG_SQL: retval [$retval] $DBI::errstr\n";
  +        print "\n";
  +    }
  +
  +    &App::sub_exit($retval) if ($App::trace);
  +    $retval;
  +}
  +
   ######################################################################
   # METADATA REPOSITORY METHODS (implements methods from App::Repository)
   ######################################################################
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.