V
Vito Corleone
Hi,
I want to make a module that execute the query and return the $sth in
wrapped form.
If you don't use the wrapper it would be like this:
## no_wrapper.pl
my $sth = $dbh->prepare("SELECT member_id, item_name FROM item");
$sth->execute();
while (my $row = $sth->fetchrow_arrayref()) {
print $row->[0];
pirnt $row->[1];
}
I want to wrap that, so I can write it like below:
## with_wrapper.pl
use Item;
my $it = Item::->new();
my $obj = $it->get_items(); ## This return $sth in wrapped form
while (my $item = $obj->each()) {
print $item->member_id();
print $item->item_name();
## etc
}
How should I write Item.pm, so it can be used as the wrapper above?
Could you please give some simple example, as I don't know where to
start. And thank you in advance.
Regards,
Vito
I want to make a module that execute the query and return the $sth in
wrapped form.
If you don't use the wrapper it would be like this:
## no_wrapper.pl
my $sth = $dbh->prepare("SELECT member_id, item_name FROM item");
$sth->execute();
while (my $row = $sth->fetchrow_arrayref()) {
print $row->[0];
pirnt $row->[1];
}
I want to wrap that, so I can write it like below:
## with_wrapper.pl
use Item;
my $it = Item::->new();
my $obj = $it->get_items(); ## This return $sth in wrapped form
while (my $item = $obj->each()) {
print $item->member_id();
print $item->item_name();
## etc
}
How should I write Item.pm, so it can be used as the wrapper above?
Could you please give some simple example, as I don't know where to
start. And thank you in advance.
Regards,
Vito