DBIx-Brev

 view release on metacpan or  search on metacpan

lib/DBIx/Brev.pm  view on Meta::CPAN

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    $dbh = $dbc unless $use_connector;
    $dbc;
}
 
sub dbh {
    $dbh = $_[0] if @_;
    $dbc = $dbh unless $use_connector;
    $dbh;
}
 
sub shift_params(&\@) {
    my ($predicate,$params) = @_;
    local $_ = shift(@$params);
    my $p = $_;
    if (eval {$predicate->($_) && 1}) {
        return $p;
    } else {
        unshift @$params,$p;
        return;
    }
}

lib/DBIx/Brev.pm  view on Meta::CPAN

178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
}
 
sub sql_query_hash
{
    my $sth = &get_sth;
    my @result;
    while (my $row  = $sth->fetchrow_hashref) { push @result,$row; }
    wantarray()?@result:\@result;
}
 
sub sql_map(&@)
{
    my $callback = shift;
    my $sth = get_sth(@_);
    my @result = ();
    my $wantresult = defined wantarray;
    local $_;
    while (defined($_ = $sth->fetch)) {
        # do copy because fetch uses the same buffer
        $_ = @$_>1?[@$_]:$_->[0];
        my @r = $callback->($_);



( run in 0.399 second using v1.01-cache-2.11-cpan-bb97c1e446a )