mysql "LIMIT ?"
am 20.02.2007 00:01:09 von rvtol+newsI created a quick-fix to get rid of the error about the quoted
LIMIT-value, but I assume this must have been solved in better ways. The
fix below is easy to enhance to also cover the "LIMIT ?,?" variant, but
I would rather see a cleaner approach. Does it exist already?
#!/usr/bin/perl
use strict;
use warnings;
use DBD::mysql;
### You can activate the code below, to get rid of
### the quoted LIMIT-value error.
# BEGIN {
# $DBD::mysql::st::__execute_org = \&DBD::mysql::st::execute;
# }
#
# { no warnings 'redefine';
#
# sub DBD::mysql::st::execute {
# for ($_[0]->{Database}{Statement}) {
# $_ = $1 . pop @_
# if m/(.* \s LIMIT \s+ ) \? \s* \z/msxi;
# }
# $DBD::mysql::st::__execute_org->(@_);
# }
# }
my $dbh = DBI->connect( qw/ dbi:mysql:MyDB user password / )
or die "Database connection failed";
my @href_rows = $dbh->selectall_hashref(
q/SELECT id, name
FROM MyTable
LIMIT ?/
, 'id'
, undef
, 42
) or die "\nError";
$dbh->disconnect();
--
Affijn, Ruud
"Gewoon is een tijger."