Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Method that returns a statement handle. #2

Merged
merged 1 commit into from

2 participants

@jkramer

I added methods with _sth appended that return a statement handle as return by DBI->execute. This should be useful in cases where you get a huge result from database and reading it all at once would be too much.

@matiu matiu merged commit 4240de2 into matiu:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 21, 2012
  1. Method that returns statement handle instead of data.

    Jonas Kramer authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 1 deletion.
  1. +13 −0 lib/SQL/Bibliosoph.pm
  2. +2 −1  t/biblio.t
View
13 lib/SQL/Bibliosoph.pm
@@ -308,6 +308,14 @@ package SQL::Bibliosoph; {
return $ret || [];
};
+ # Get statement handle instead of results.
+ $name_row = $name . '_sth';
+ *$name_row = sub {
+ my ($that) = shift;
+ $self->d('sth ', $name, @_);
+ return $self->queries()->{$name}->select_do([@_]);
+ };
+
last SW;
};
@@ -562,6 +570,11 @@ SQL::Bibliosoph - A SQL Statements Library
my $products_array_of_hash_ref
= $bs->h_get_products($country,$price,$start,$limit);
+
+ # To get a prepared and executed statement handle, append '_sth':
+ my $sth = $bs->get_products_sth($country, $price, $start, $limit);
+
+
# Selecting only one row (add row_ at the begining)
# Query:
View
3  t/biblio.t
@@ -45,6 +45,7 @@ is(ref($q),'ARRAY','Simple query 3');
$q = $bb->rowh_USERS3();
is(ref($q),'HASH','Simple query 3');
-
+$q = $bb->USERS3_sth();
+is(ref($q), 'DBI::st', 'Simple query 3 STH');
done_testing();
Something went wrong with that request. Please try again.