original_string: public function search_references_count($reference) {
          global $DB;
  
          if (is_null($reference)) {
              throw new coding_exception('NULL is not a valid reference to an external file');
          }
  
          // Give {@link self::unpack_reference()} a chance to throw exception if the
          // reference is not in a valid format.
          self::unpack_reference($reference);
  
          $referencehash = sha1($reference);
  
          $sql = "SELECT COUNT(f.id)
                    FROM {files} f
                    JOIN {files_reference} r ON f.referencefileid = r.id
                    JOIN {repository_instances} ri ON r.repositoryid = ri.id
                   WHERE r.referencehash = ?
                         AND (f.component <> ? OR f.filearea <> ?)";
  
          return (int)$DB->count_records_sql($sql, array($referencehash, 'user', 'draft'));
      }
code: public function search_references_count($reference) {
          global $DB;
  
          if (is_null($reference)) {
              throw new coding_exception('NULL is not a valid reference to an external file');
          }
  
          // Give {@link self::unpack_reference()} a chance to throw exception if the
          // reference is not in a valid format.
          self::unpack_reference($reference);
  
          $referencehash = sha1($reference);
  
          $sql = "SELECT COUNT(f.id)
                    FROM {files} f
                    JOIN {files_reference} r ON f.referencefileid = r.id
                    JOIN {repository_instances} ri ON r.repositoryid = ri.id
                   WHERE r.referencehash = ?
                         AND (f.component <> ? OR f.filearea <> ?)";
  
          return (int)$DB->count_records_sql($sql, array($referencehash, 'user', 'draft'));
      }
code_tokens: public function search_references_count ( $ reference ) { global $ DB ; if ( is_null ( $ reference ) ) { throw new coding_exception ( 'NULL is not a valid reference to an external file' ) ; } // Give {@link self::unpack_reference()} a chance to throw exception if the // reference is not in a valid format. self :: unpack_reference ( $ reference ) ; $ referencehash = sha1 ( $ reference ) ; $ sql = "SELECT COUNT(f.id)
                    FROM {files} f
                    JOIN {files_reference} r ON f.referencefileid = r.id
                    JOIN {repository_instances} ri ON r.repositoryid = ri.id
                   WHERE r.referencehash = ?
                         AND (f.component <> ? OR f.filearea <> ?)" ; return ( int ) $ DB -> count_records_sql ( $ sql , array ( $ referencehash , 'user' , 'draft' ) ) ; }
docstring: Returns the number of aliases that refer to some stored_file via the given reference
  
  All repositories that provide access to a stored_file are expected to use
  {@link self::pack_reference()}. This method can't be used if the given reference
  does not use this format or if you are looking for references to an external file
  (for example it can't be used to count aliases that refer to a given Dropbox or
  Box.net file).
  
  Aliases in user draft areas are not counted.
  
  @param string $reference identification of the referenced file
  @return int
docstring_tokens: Returns the number of aliases that refer to some stored_file via the given reference