DBD-D1

 view release on metacpan or  search on metacpan

lib/DBD/D1.pm  view on Meta::CPAN

    my ($outer, $sth) = DBI::_new_sth($dbh, { Statement => $statement });

    # Count ? placeholders outside quoted strings
    (my $copy = $statement) =~ s/'[^']*'|"[^"]*"//g;
    my $num_params = () = $copy =~ /\?/g;

    $sth->{NUM_OF_PARAMS}    = $num_params;
    $sth->{d1_params}        = [];
    $sth->{d1_rows_affected} = undef;
    $sth->{d1_result_data}   = undef;
    $sth->{d1_cursor}        = 0;

    return $outer;
}

sub commit {
    my ($dbh) = @_;
    warn "DBD::D1: commit() has no effect – D1 is AutoCommit only\n"
        if $dbh->{Warn};
    return 1;
}

lib/DBD/D1.pm  view on Meta::CPAN

            map { my $r = $_; [ @{$r}{@col_names} ] } @$rows
        ];
    } else {
        $sth->{NAME}           = [];
        $sth->{NAME_lc}        = [];
        $sth->{NAME_uc}        = [];
        $sth->{NUM_OF_FIELDS}  = 0;
        $sth->{d1_result_data} = [];
    }

    $sth->{d1_cursor}        = 0;
    $sth->{d1_rows_affected} = $meta->{changes} // $meta->{rows_affected} // 0;
    $sth->{Active}           = 1;

    return $sth->{d1_rows_affected} || '0E0';
}

sub fetchrow_arrayref {
    my ($sth) = @_;
    my $data   = $sth->{d1_result_data} or return undef;
    my $cursor = $sth->{d1_cursor};

    if ($cursor >= scalar @$data) {
        $sth->{Active} = 0;
        return undef;
    }

    $sth->{d1_cursor}++;
    return $data->[$cursor];
}

*fetch = \&fetchrow_arrayref;

sub fetchall_arrayref {
    my ($sth, $slice, $max_rows) = @_;
    my $data = $sth->{d1_result_data} // [];
    my @result;

    for my $row (@$data) {

lib/DBD/D1.pm  view on Meta::CPAN

    $sth->{Active} = 0;
    return \@result;
}

sub rows   { $_[0]->{d1_rows_affected} // -1 }

sub finish {
    my ($sth) = @_;
    $sth->{Active}          = 0;
    $sth->{d1_result_data}  = undef;
    $sth->{d1_cursor}       = 0;
    return 1;
}

sub FETCH {
    my ($sth, $attr) = @_;
    return $sth->{$attr} if $attr =~ /^d1_/;
    return $sth->SUPER::FETCH($attr);
}

sub STORE {



( run in 0.865 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )