JayBee has asked for the wisdom of the Perl Monks concerning the following question:
Here's another using STDOUT after SELECT - FROM -, to the disconnect:use warnings; use DBI; use DBD::mysql; use CGI qw( :standard ); use CGI::Carp "fatalsToBrowser"; print header, start_html('SQL Must Work!'); my $dbh = DBI->connect("DBI:mysql:data:server","uname","pass") or die( "Could not make connection to database: $DBI::errstr" ); $dbh->do( qq{SELECT Tab1, Tab2, Tab3 FROM UData } ); while (my @row = $dbh->fetchrow_array ) { my ( $item0, $item1, $item2 ) = @row; if ($item0 >= $somevalue) { print br, "$item0"; } } warn( $DBI::errstr ) if ( $DBI::err ); $dbh->disconnect(); print '<h2>All Done</h2>'; print end_html;
my @array; while (my @row = $dbh->fetchrow_array ) { write (); } format STDOUT = @<<<<<<<<<<@<<<<<<<<<<<<<@<<<<<<<< $array[0], $array[1], $array[2] .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fetchrow_array DBI
by Mr. Muskrat (Canon) on Feb 01, 2004 at 05:26 UTC | |
|
Re: fetchrow_array DBI
by dws (Chancellor) on Feb 01, 2004 at 05:26 UTC | |
|
Re: fetchrow_array DBI
by b10m (Vicar) on Feb 01, 2004 at 05:29 UTC | |
|
Re: fetchrow_array DBI
by Zaxo (Archbishop) on Feb 01, 2004 at 05:23 UTC | |
|
Re: fetchrow_array DBI
by JayBee (Scribe) on Feb 02, 2004 at 01:28 UTC | |
by dws (Chancellor) on Feb 02, 2004 at 02:50 UTC |