public static function count_user_subscriptions_for_course($courseid, $userid = 0) {
        global $DB, $USER;
        if ($userid == 0) {
            $userid = $USER->id;
        }
        $sql = self::get_subscription_join_rule_sql(true);
        $sql .= "WHERE s.courseid = :courseid AND s.userid = :userid";

        return $DB->count_records_sql($sql, array('courseid' => $courseid, 'userid' => $userid));
    }
public static function count_user_subscriptions_for_course($courseid, $userid = 0) {
        global $DB, $USER;
        if ($userid == 0) {
            $userid = $USER->id;
        }
        $sql = self::get_subscription_join_rule_sql(true);
        $sql .= "WHERE s.courseid = :courseid AND s.userid = :userid";

        return $DB->count_records_sql($sql, array('courseid' => $courseid, 'userid' => $userid));
    }
public static function count_user_subscriptions_for_course ( $ courseid , $ userid = 0 ) { global $ DB , $ USER ; if ( $ userid == 0 ) { $ userid = $ USER -> id ; } $ sql = self :: get_subscription_join_rule_sql ( true ) ; $ sql .= "WHERE s.courseid = :courseid AND s.userid = :userid" ; return $ DB -> count_records_sql ( $ sql , array ( 'courseid' => $ courseid , 'userid' => $ userid ) ) ; }
Get count of subscriptions for a given user in a given course.

@param int $courseid course id.
@param int $userid Id of the user for which the subscription needs to be fetched. Defaults to $USER;

@return int number of subscriptions
Get count of subscriptions for a given user in a given course .