Added sql_ceil() helper function. MDL-15336

This commit is contained in:
stronk7
2008-06-28 18:15:38 +00:00
parent 05ac554f60
commit 45516d902c
+17
View File
@@ -2160,6 +2160,23 @@ function sql_null_from_clause() {
}
}
/**
* 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
*/
function sql_ceil($fieldname) {
global $CFG;
switch ($CFG->dbfamily) {
case 'mssql':
return ' CEILING(' . $fieldname . ')';
break;
default:
return ' CEIL(' . $fieldname . ')';
}
}
/**
* Prepare a SQL WHERE clause to select records where the given fields match the given values.
*