original_string: 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);
      }
code: 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);
      }
code_tokens: 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 ) ; }
docstring: 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
docstring_tokens: Returns the number of expired_contexts instances that match the provided level and status .