Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 106944
Status: rejected
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: porton [...] narod.ru
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.633
Fixed in: (no value)



Subject: Feature suggestion: do_cached
I suggest to add new routine to shorten a common use case: sub do_cached { my ($dbh, $statement, @bind_values) = @_; my $sth = $dbh->prepare_cached($statement); return $statement->execute(@bind_values); }
From: porton [...] narod.ru
On Mon Sep 07 17:03:09 2015, PORTON wrote: Show quoted text
> I suggest to add new routine to shorten a common use case: > > sub do_cached { > my ($dbh, $statement, @bind_values) = @_; > my $sth = $dbh->prepare_cached($statement); > return $statement->execute(@bind_values); > }
# Correction: sub do_cached { my ($dbh, $statement, @bind_values) = @_; my $sth = $dbh->prepare_cached($statement); return $sth->execute(@bind_values); }
On 2015-09-07 17:04:18, PORTON wrote: Show quoted text
> On Mon Sep 07 17:03:09 2015, PORTON wrote:
> > I suggest to add new routine to shorten a common use case: > > > > sub do_cached { > > my ($dbh, $statement, @bind_values) = @_; > > my $sth = $dbh->prepare_cached($statement); > > return $statement->execute(@bind_values); > > }
> > # Correction: > sub do_cached { > my ($dbh, $statement, @bind_values) = @_; > my $sth = $dbh->prepare_cached($statement); > return $sth->execute(@bind_values); > } >
Probably $attr should also be in the arguments (like for do()), and the return code should look like described in https://metacpan.org/source/TIMB/DBI-1.634/DBI.pm#L4469
Thanks for the suggestion. I've given it some thought. Allowing for the $attr, I don't see enough value gained to be worth adding a do_cached method. This: $result = $dbh->do_cached($statement, undef, @bind_values); isn't significantly shorter than: $result = $dbh->prepare_cached($statement)->execute(@bind_values);