Howdy!

 

I am having a small problem using DBI and HTML::Pager and was wondering if somebody could tell me where I am going wrong.  First, I'll state that I have normally used "fetchrow_array" with H-T and had no problems. I read that you need to use "selectall_arrayref", which I have never used - so I am very unfamiliar with them.  I get no errors, but I also get no data passed to the template when I should receive 52 rows returned to the template.

 

Here's the code:

            $strSQL = qq/SELECT sessionkey, security, username, realname FROM UserTable ORDER BY sessionkey/;

            $hST = $hDB->prepare_cached($strSQL) or die "Cannot Prepare the SQL Statement: DBI::errstr\n";

            my $tmpl = HTML::Template->new(filename => 'testtmpl.tmpl');

            my $query = new CGI;                # This script does not use this - future ref.

 

            my $data = "$hDB->selectall_arrayref($hST)" or die "Cannot Execute the SQL Statement: $DBI::errstr\n";

 

                        my $get_data_sub = sub {

                        my ($offset, $rows) = @_;

                        my @return_array;

                        for (my $x = 0; $x < $rows; $x++) {

                                    push(@return_array,

[ $data[$offset + $x ]{sessionkey},

                                    $data[$offset + $x ]{security}, 

                                    $data[$offset + $x ]{username}, 

                                    $data[$offset + $x ]{realname} 

                                    ]

                  );

                        }

               return \@return_array;

            };          # End of GetDataSub Routine

 

            # create a Pager object

            my $pager = HTML::Pager->new(

                               # required parameters

                                    template => $tmpl,

                                    query => $query,

                                    get_data_callback => $get_data_sub,

                                    rows => 52,

                                    page_size => 5

                              );

 

 print $pager->output;

 

Any help would be greatly appreciated.

Thanx, Jeff Pelkey

Reply via email to