diff --git a/classes/results.php b/classes/results.php
index ccb22e52862fabecf3223f54a4bde2237db61552..ee969ff62c9d7f2c70ee31fad4a446b4c54df104 100644
--- a/classes/results.php
+++ b/classes/results.php
@@ -161,9 +161,9 @@ class results {
                   {$join}
                   {$where}
                   {$order_by}
-                  LIMIT {$this->limit}
-                  OFFSET {$this->offset}
-                ", $args);
+                ", $args,
+                $this->offset,
+                $this->limit);
     }
 
     /**
@@ -312,8 +312,8 @@ class results {
      * @param array $args Used for placeholders
      * @return array
      */
-    protected function get_sql_results($query, $args) {
+    protected function get_sql_results($query, $args, $limitfrom = 0, $limitnum = 0) {
         global $DB;
-        return $DB->get_records_sql($query, $args);
+        return $DB->get_records_sql($query, $args, $limitfrom, $limitnum);
     }
 }
diff --git a/mod_form.php b/mod_form.php
index 62f8f37d852cc4b2f08ab9fcbf661a115d29cd53..c3b551303172098158bbbc66c9739d011a023bc9 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -121,7 +121,7 @@ class mod_hvp_mod_form extends moodleform_mod {
         }
 
         // Determine default action
-        if ($content === null && $DB->get_field_sql("SELECT id FROM {hvp_libraries} WHERE runnable = 1 LIMIT 1") === false) {
+        if ($content === null && $DB->get_field_sql("SELECT id FROM {hvp_libraries} WHERE runnable = 1", null, IGNORE_MULTIPLE) === false) {
           $defaultvalues['h5paction'] = 'upload';
         }