in reply to Re: My doubts about using fetchall_arrayref
in thread My doubts about using fetchall_arrayref

That is interesting, do you mean by "pass the function a list of columns you want" like this?
... my $sql = "select id, account_number, date from my_table where id <>'' order by date desc"; my @columns = qw( id account_number box ); my $results = $self->_all_data($sql, \@columns); ...

Replies are listed 'Best First'.
Re^3: My doubts about using fetchall_arrayref
by CountOrlok (Friar) on Apr 02, 2013 at 14:02 UTC
    Yes. Though, to be nit-picky, in your example the third item in the list should be date, not box.

      As there is redundant information in the sql statement and the list of columns, you could also do

      ... my @columns = qw( id account_number date ); my $sql = "select ".join( ",", @columns). " from my_table where id <>'' order by date desc"; my $results = $self->_all_data($sql, \@columns); ...
        hdb: see my post below about "the_date". It could be that the query is going to do some reformatting of the columns (convert, concatenation, etc) and so trying to join the @columns into the $sql may not be a good idea.
      Yes, my fault, but doing that whay I am getting an error now with HTML::Template:
      There has been an error: HTML::Template::param() : attempt to set para +meter 'results' with a scalar - parameter is not a TMPL_VAR!<br> Any idea why?
        can you show the code that is populating the template file?