return '((' . $int1 . ') ^ (' . $int2 . '))';
}
+ /**
+ * Returns the SQL text to be used in order to perform module '%'
+ * opration - remainder after division
+ *
+ * @param integer int1 first integer in the operation
+ * @param integer int2 second integer in the operation
+ * @return string the piece of SQL code to be used in your statement.
+ */
+ public function sql_modulo($int1, $int2) {
+ return '((' . $int1 . ') % (' . $int2 . '))';
+ }
+
/**
* Returns the correct CEIL expression applied to fieldname.
*
$this->assertEqual($DB->get_field_sql($sql), 9);
}
+ function test_sql_modulo() {
+ $DB = $this->tdb;
+ $sql = "SELECT ".$DB->sql_modulo(10, 7)." AS number ".$DB->sql_null_from_clause();
+ $this->assertEqual($DB->get_field_sql($sql), 3);
+ }
+
function test_sql_ceil() {
$DB = $this->tdb;
$sql = "SELECT ".$DB->sql_ceil(665.666)." AS number ".$DB->sql_null_from_clause();