]> git.mjollnir.org Git - moodle.git/commitdiff
Added sql_ceil() helper method. MDL-15336
authorstronk7 <stronk7>
Sat, 28 Jun 2008 18:25:25 +0000 (18:25 +0000)
committerstronk7 <stronk7>
Sat, 28 Jun 2008 18:25:25 +0000 (18:25 +0000)
lib/dml/moodle_database.php
lib/dml/mssql_adodb_moodle_database.php

index b4cfe68b7091970246ca78e03b33eff7ee439c0f..f2bb68daa1165b360683ac5ff6b2ba2e55cc17f3 100644 (file)
@@ -1208,6 +1208,16 @@ abstract class moodle_database {
         return '';
     }
 
+    /**
+     * Returns the correct CEIL expression applied to fieldname
+     * @param string fieldname the field (or expression) we are going to ceil
+     * @return string the piece of SQL code to be used in your ceiling statement
+     * Most DB use CEIL(), hence it's the default.
+     */
+    public function sql_ceil($fieldname) {
+        return ' CEIL(' . $fieldname . ')';
+    }
+
     /**
      * Returns the SQL to be used in order to CAST one CHAR column to INTEGER.
      *
index a635231ea64f8f97b988aefa5c4c086c18934d9c..539f1e2c37fba0fe606fbac606cb4dc1ca0ac612 100644 (file)
@@ -111,6 +111,10 @@ class mssql_adodb_moodle_database extends adodb_moodle_database {
         return SQL_PARAMS_QM;
     }
 
+    public function sql_ceil($fieldname) {
+        return ' CEILING(' . $fieldname . ')';
+    }
+
     public function sql_cast_char2int($fieldname, $text=false) {
         if (!$text) {
             return ' CAST(' . $fieldname . ' AS INT) ';