DB-Handy

 view release on metacpan or  search on metacpan

lib/DB/Handy.pm  view on Meta::CPAN


  my $code = $dbh->err;

Return the error code from the most recent failed operation (always 1 for
any error, 0 for no error).  Reset together with C<errstr>.
Analogous to C<$DBI::err>.
Compatible with DBI.

=head2 ping()

  my $alive = $dbh->ping;

Return true while the handle is usable, false after C<disconnect>.  There
is no server to reach, so this reports the handle's own state.
Compatible with DBI.

=head2 AutoCommit()

  my $ac = $dbh->AutoCommit;   # always 1

Always returns C<1>.  This method, not the C<< $dbh->{AutoCommit} >> hash

t/1017_regression.t  view on Meta::CPAN

    # -------------------------------------------------------------------
    # R1 -- _load_schema() must not touch the caller's $_
    # -------------------------------------------------------------------
    sub {
        $db->execute('CREATE TABLE r1 (id INT)');
        my @ids = (11, 22, 33);
        for (@ids) { $db->execute("INSERT INTO r1 (id) VALUES ($_)") }
        is(join(',', @ids), '11,22,33', 'R1 - caller @_ array survives execute()');
    },
    sub {
        my $alive = 1;
        # A read-only value would die with "Modification of a read-only value".
        eval {
            $db->{_tables} = {};
            for (44) { $db->execute("INSERT INTO r1 (id) VALUES ($_)") }
        };
        $alive = 0 if $@;
        ok($alive, 'R1 - constant list element is not modified');
    },
    sub {
        $db->{_tables} = {};
        my @seen = map { $db->execute('SELECT id FROM r1 WHERE id = 11'); $_ } (1, 2, 3);
        is(join(',', @seen), '1,2,3', 'R1 - $_ intact inside map');
    },

    # -------------------------------------------------------------------
    # R2 -- LIMIT / OFFSET with no WHERE / ORDER BY / GROUP BY
    # -------------------------------------------------------------------



( run in 1.367 second using v1.01-cache-2.11-cpan-14f38c9f855 )