Subject: | Class-DBI-Pager can't work with $class->sth_to_objects |
use ShopFloor::CDBI::SFC::DeptDBH;
use ShopFloor::CDBI::SFC::WorkCenterDBH;
use ShopFloor::CDBI::SFC::FlowctrlDBH;
my $dbh = SFC::FlowctrlD->db_Main;
my $sql = '
select d.wkc_id, w.wkc_code, w.wkc_name
from sfc_flowctrl_detail d,
sfc_workcenter w
where d.flowctrlh_id = 1
and d.wkc_id = w.wkc_id
order by w.wkc_code
';
my $sth = $dbh->prepare( $sql );
$sth->execute;
# my @rows = $sth->fetchrow_array; #---get 3 rows
my $pager = SFC::FlowctrlD->pager( 10 , 1 ); # ($items_per_page,
$current_page)
my @rows = $pager->sth_to_objects( $sth );
print "tot recs = ", $#rows, "\n"; # return value -1 : get
no rows
foreach my $rec ( @rows ) {
print "wkc_id =", $rec->wkc_id, " ";
print "wkc =", $rec->wkc_id->wkc_code, " ";
print $rec->wkc_id->wkc_name, " \n";
}