From: timriker Date: Tue, 6 Jul 2004 22:24:56 +0000 (+0000) Subject: older mysql lacks OFFSET support X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=385903d4c212973705ed2195324e2ce1ca028137;p=infobot.git older mysql lacks OFFSET support git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@986 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/blootbot/src/dbi.pl b/blootbot/src/dbi.pl index 138c5cc..f4c89d3 100644 --- a/blootbot/src/dbi.pl +++ b/blootbot/src/dbi.pl @@ -516,7 +516,10 @@ sub randKey { my ($table, $select) = @_; my $rand = int(rand(&countKeys($table))); my $query = "SELECT $select FROM $table LIMIT 1 OFFSET $rand"; - + if ($param{DBType} =~ /^mysql$/i) { + # WARN: only newer MySQL supports "LIMIT limit OFFSET offset" + $query = "SELECT $select FROM $table LIMIT $rand,1"; + } my $sth = $dbh->prepare($query); &SQLDebug($query); &WARN("randKey($query)") unless $sth->execute;