perlquestion
THuG
<p>Sorry, I've tried searching, I still can't get it to work.</p>
<code>
#!C:\Perl\bin
use strict;
use DBI;
my $fromHost = "someServer";
my $fromDB = "someDB";
my $fromTable = "someTable";
my @fromFields = ("Field 1", "Field 2", "Field 3");
my $fromDSN = "dbi:mysqlPP:database=$fromDB;host=$fromHost";
my $dbh = DBI->connect($fromDSN, "", "");
my $drh = DBI->install_driver("mysqlPP");
my $rs = $dbh->selectall_arrayref("SELECT '" . join("','", @fromFields) . "' FROM $fromTable");
$dbh->disconnect();
foreach my $myRow (@$rs) {
print "@$myRow\n";
foreach my $myElem (@$myRow) {
print "$myElem,";
}
print "\n";
}
</code>
<p>This will print the following:</p>
<pre>
Field 1 Field 2 Field 3
Field 1,Field 2,Field 3,
</pre>
<p>It will repeat these two lines for each record in the table, but it will never return any data from table. I do admit, I need to know the field names (the hardcoded part will eventually be removed, and fields can be supplied at runtime), but I need to get to the data, too. What am I doing wrong, and in which document should I've found the answer?</p>