]> git.donarmstrong.com Git - infobot.git/blobdiff - src/dbi.pl
ws
[infobot.git] / 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;