original_string: public function search_references($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 ".self::instance_sql_fields('f', 'r')."
                    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 <> ?)";
  
          $rs = $DB->get_recordset_sql($sql, array($referencehash, 'user', 'draft'));
          $files = array();
          foreach ($rs as $filerecord) {
              $files[$filerecord->pathnamehash] = $this->get_file_instance($filerecord);
          }
          $rs->close();
  
          return $files;
      }
code: public function search_references($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 ".self::instance_sql_fields('f', 'r')."
                    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 <> ?)";
  
          $rs = $DB->get_recordset_sql($sql, array($referencehash, 'user', 'draft'));
          $files = array();
          foreach ($rs as $filerecord) {
              $files[$filerecord->pathnamehash] = $this->get_file_instance($filerecord);
          }
          $rs->close();
  
          return $files;
      }
code_tokens: public function search_references ( $ 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 " . self :: instance_sql_fields ( 'f' , 'r' ) . "
                    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 <> ?)" ; $ rs = $ DB -> get_recordset_sql ( $ sql , array ( $ referencehash , 'user' , 'draft' ) ) ; $ files = array ( ) ; foreach ( $ rs as $ filerecord ) { $ files [ $ filerecord -> pathnamehash ] = $ this -> get_file_instance ( $ filerecord ) ; } $ rs -> close ( ) ; return $ files ; }
docstring: Returns all 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 search for all aliases that refer to a given
  Dropbox or Box.net file).
  
  Aliases in user draft areas are excluded from the returned list.
  
  @param string $reference identification of the referenced file
  @return array of stored_file indexed by its pathnamehash
docstring_tokens: Returns all aliases that refer to some stored_file via the given reference