LPM: DBI woes
Wesley
wsheldahl at qx.net
Wed Feb 23 23:24:50 CST 2000
Rich,
When it prints every other record, does it print a blank line in
between? If so, then $day is empty and there's something wrong with the
data or the way it's being fetched. If not, I wonder if fetchrow_array
could possibly be grabbing two days at a time, and discarding the second
one since you just have one scalar to hold the results. I've always
used while ($sth->fetch) and haven't touched fetchrow_array, but I
always thought fetchrow_array was for when you wanted to get several
fields at once. Looks like you're just getting one value each time
through the loop. Single-stepping through the loop with a debugger
might help here.
So in a nutshell, I would try changing that one line to:
$day = $sth->fetch;
as long as you're sure it will always return a record and don't have to
test for that possibility. I would also use $dbh->prepare_cached as
David suggested because I think the most recent DBI docs recommend it,
though I don't think that will affect your problem one way or the
other. OTOH it might! :-)
Another option would be to bind the column ahead of time, just for the
sake of doing it differently. I think this would look something like:
$sth = $dbh->prepare_cached($sql);
$sth->bind_col(\$day);
foreach $ID (@conflicts)
$sth->execute($ID);
$sth->fetch;
print "$day\n";
}
only with proper syntax etc.
Hope something here helps, if you haven't already solved this.
--
Wes Sheldahl
wsheldahl at qx.net
More information about the Lexington-pm
mailing list