MDL-58754 competency: Change query for DISTINCT COUNT

This commit is contained in:
Andrew Nicols 2017-05-02 14:48:35 +08:00
parent 06e3b6d8ba
commit 458e5f66c2

View File

@ -676,7 +676,8 @@ class competency extends persistent {
public static function share_same_framework(array $ids) {
global $DB;
list($insql, $params) = $DB->get_in_or_equal($ids);
return $DB->count_records_select(self::TABLE, "id $insql", $params, "COUNT(DISTINCT(competencyframeworkid))") == 1;
$sql = "SELECT COUNT('x') FROM (SELECT DISTINCT(competencyframeworkid) FROM {" . self::TABLE . "} WHERE id {$insql}) f";
return $DB->count_records_sql($sql, $params) == 1;
}
/**