in reply to Re: Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBI
in thread Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBI

SELECT *

I sometimes use 'select *' but it is usually combined with something like:

$sth->execute(); my @columns = $sth->{NAME_uc}; my %row; $sth->bind_columns( \@row{@columns} ); while ( $sth->fetch() ) { ... }
But then you have to be watch out for columns that get renamed or deleted that you explicitly use in the while loop, etc. (and all selected fields must have an explicit name, e.g., you need an alias for calculated fields).
  • Comment on Re^2: Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBI
  • Download Code

Replies are listed 'Best First'.
Re^3: Extra iteration while fetching 'fetchrow_array' in DBI and standerd way of using DBI
by roboticus (Chancellor) on Jun 16, 2007 at 04:22 UTC
    runrig:

    I like the trick to bind the columns up, but I still wouldn't use a select * if only because someone might WTF-ify the database and you'll be reading quite a bit more data than you need. Also, future maintainers won't know which columns are significant without significant spelunking through the code.

    --roboticus