LPM: DBI woes

Rich Bowen rbowen at rcbowen.com
Wed Feb 23 20:35:39 CST 2000


OK, I've been beating my head against this for about 30 minutes. Can one
of you fine folks tell me the obvious thing that I'm missing?

This:

foreach $ID (@conflicts)	{
	$sth = $dbh->prepare("select day from reservation
			where ID = $ID");
	$sth->execute;
	($day) = $sth->fetchrow_array;
	print "$day\n";
}

is printing a list of days, as expected.

However, this (which is, in theory, better)


$sth = $dbh->prepare("select day from reservation
			where ID = ?");
foreach $ID (@conflicts)	{
	$sth->execute($ID);
	($day) = $sth->fetchrow_array;
	print "$day\n";
}

Only prints every other record.

Am I missing something obvious? I'd like to do it the faster way, but
it's giving me bogus results.

Rich
-- 
http://www.ApacheUnleashed.com/
Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt



More information about the Lexington-pm mailing list