Added sql_ceil() helper function. MDL-15336
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user