]> git.donarmstrong.com Git - infobot.git/commitdiff
older mysql lacks OFFSET support
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 6 Jul 2004 22:24:56 +0000 (22:24 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 6 Jul 2004 22:24:56 +0000 (22:24 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@986 c11ca15a-4712-0410-83d8-924469b57eb5

src/dbi.pl

index 138c5ccd360f2018b28e18c2331a0dfe55f69c2e..f4c89d3a80e5caf2e096c6067b293b8feffafc0b 100644 (file)
@@ -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;