]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: fix SQL CAST()s to work on MySQL and PostgreSQL
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:48:31 +0000 (07:48 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:48:31 +0000 (07:48 +0000)
CAST() target types aren't very portable. Use DECIMAL which works
for MySQL and Pg.

DECIMAL does seem to be supported in Oracle - but the syntax seems
different. We may still need a compat function.

lib/accesslib.php

index a879f71f3497f8dcc3555a7a0d3fb60e836e93fd..456e8cc59619ba3522923790ea15dc8b7d69405e 100755 (executable)
@@ -4586,7 +4586,7 @@ function get_dirty_contexts($time) {
     $sql = "SELECT name, value 
             FROM {$CFG->prefix}config_plugins
             WHERE plugin='accesslib/dirtycontexts'
-                  AND CAST(value AS integer) > $time";
+                  AND CAST(value AS DECIMAL) > $time";
     if ($ctx = get_records_sql($sql)) {
         return $ctx;
     }
@@ -4620,7 +4620,7 @@ function cleanup_dirty_contexts() {
     global $CFG;
     
     $sql = "plugin='accesslib/dirtycontexts' AND
-                  CAST(value to integer) < " . time() - $CFG->sessiontimeout;
+                  CAST(value AS DECIMAL) < " . time() - $CFG->sessiontimeout;
     delete_records_select('config_plugins', $sql);
 }