public static function get_record_count_by_contextlevel($contextlevel = null, $status = false) {
        global $DB;

        $sql = "SELECT COUNT(1)
                  FROM {" . self::TABLE . "} expiredctx
                  JOIN {context} ctx
                    ON ctx.id = expiredctx.contextid";

        $conditions = [];
        $params = [];

        if (!empty($contextlevel)) {
            $conditions[] = "ctx.contextlevel = :contextlevel";
            $params['contextlevel'] = intval($contextlevel);
        }

        if ($status !== false) {
            $sql .= " AND expiredctx.status = :status";
            $params['status'] = intval($status);
        }
        if (!empty($conditions)) {
            $sql .= ' WHERE ' . implode(' AND ', $conditions);
        }

        return $DB->count_records_sql($sql, $params);
    }
public static function get_record_count_by_contextlevel($contextlevel = null, $status = false) {
        global $DB;

        $sql = "SELECT COUNT(1)
                  FROM {" . self::TABLE . "} expiredctx
                  JOIN {context} ctx
                    ON ctx.id = expiredctx.contextid";

        $conditions = [];
        $params = [];

        if (!empty($contextlevel)) {
            $conditions[] = "ctx.contextlevel = :contextlevel";
            $params['contextlevel'] = intval($contextlevel);
        }

        if ($status !== false) {
            $sql .= " AND expiredctx.status = :status";
            $params['status'] = intval($status);
        }
        if (!empty($conditions)) {
            $sql .= ' WHERE ' . implode(' AND ', $conditions);
        }

        return $DB->count_records_sql($sql, $params);
    }
public static function get_record_count_by_contextlevel ( $ contextlevel = null , $ status = false ) { global $ DB ; $ sql = "SELECT COUNT(1)
                  FROM {" . self :: TABLE . "} expiredctx
                  JOIN {context} ctx
                    ON ctx.id = expiredctx.contextid" ; $ conditions = [ ] ; $ params = [ ] ; if ( ! empty ( $ contextlevel ) ) { $ conditions [ ] = "ctx.contextlevel = :contextlevel" ; $ params [ 'contextlevel' ] = intval ( $ contextlevel ) ; } if ( $ status !== false ) { $ sql .= " AND expiredctx.status = :status" ; $ params [ 'status' ] = intval ( $ status ) ; } if ( ! empty ( $ conditions ) ) { $ sql .= ' WHERE ' . implode ( ' AND ' , $ conditions ) ; } return $ DB -> count_records_sql ( $ sql , $ params ) ; }
Returns the number of expired_contexts instances that match the provided level and status.

@param int $contextlevel
@param bool $status
@return int
@throws dml_exception
Returns the number of expired_contexts instances that match the provided level and status .