use strict; use warnings; use DBI; my $dbh = DBI->connect( 'DBI:mysql:test', 'foo', 'bar' ) or die; my $lon = -0.232323127347249; my $sql = qq| SELECT lon,lat,location_id FROM lat_long WHERE lon>= $lo +n|; my $sth = $dbh->prepare($sql); $sth->execute(); print STDERR "Rows not using placeholders ".$sth->rows."\n"; $sql = qq| SELECT lon,lat,location_id FROM lat_long WHERE lon >= ?|; $sth = $dbh->prepare($sql); $sth->execute($lon); print STDERR "Rows using placeholders ".$sth->rows."\n"; __END__
create table lat_long(lon double not null, lat double not null, locati +on_id integer); insert into lat_long (location_id, lat, lon) values(44977, 48.3547, 11 +.7875); insert into lat_long (location_id, lat, lon) values(53280, 48.1369, 11 +.5456); insert into lat_long (location_id, lat, lon) values(53281, 48.1394, 11 +.5454); insert into lat_long (location_id, lat, lon) values(53282, 47.6869, 11 +.7609); insert into lat_long (location_id, lat, lon) values(53283, 48.3547, 11 +.7875); insert into lat_long (location_id, lat, lon) values(60105, 48.3547, 11 +.7875); insert into lat_long (location_id, lat, lon) values(80766, 48.3507, 11 +.7328); insert into lat_long (location_id, lat, lon) values(71776, 48.1435, 11 +.5574); insert into lat_long (location_id, lat, lon) values(65883, 48.1269, 11 +.6363); insert into lat_long (location_id, lat, lon) values(65884, 48.1515, 11 +.6178);
Update Tue Dec 11 14:48:09 CET 2007: Re-ran using data supplied by ropey, still the same results.$ perl 656378.pl Rows not using placeholders 10 Rows using placeholders 10
In reply to Re: Placeholders and Negative Numbers..
by andreas1234567
in thread Placeholders and Negative Numbers..
by ropey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |