2012-03-24 4 views
0

drupal 7에서 데이터 모듈을 사용하고 있으며 내 테이블을 보여주는보기를 만들었습니다.데이터 모듈의 BLOB

  • 는하지만 내 테이블에 방울을 가지고이이 content.Is 내가 클릭하면 블롭 다운로드해야하는 링크와 파일로 표시 얻을 수있는 방법으로 내 페이지를 작성한다.
  • 또한 데이터 모듈이 settings.php에 언급 된 기본 drupal 데이터베이스와 다른 데이터베이스의 테이블에 액세스 할 수 있습니다. 필요한 테이블이있는 settings.php에 다른 데이터베이스를 추가했지만 채택 할 수 없습니다 (고아가있는 테이블 목록에 표시되지 않습니다.) 데이터 모듈이 기본 데이터베이스가 아닌 새 데이터베이스 만 볼 수 있도록 변경할 수있는 곳이 있습니까

답변

0

첫 번째 문제가 수정되었습니다. theme.inc에서이 작업을 수행하면

if($vars['fields'][$field] == 'content') 
    { 
     $field_output = "<form action=\"download.php\"  
method=\"POST\"> 
     <input type=\"submit\" name=\"download\" value=\"Download\"> 
      <input type=\"hidden\" name=\"did\" value=\"$num+1\"> 
       </form>"; 

    } 

이고 download.php에는 다음과 같은 것이 있어야합니다.

<?php 

if(isset($_POST['id'])) 
{ 
    $table = 'tablename'; 
    $download_id = $_POST['id']; 
    $q="SELECT * FROM {$table} where id = $download_id"; 
    $link = mysqli_connect(...); 
    $res = mysqli_query($link,$q); 
    if($res) 
    { 
    $row = mysqli_fetch_assoc($res); 
    $id = $row['id']; 
    $name = $row['name']; 
    $status = $row['status']; 
    $content = $row['content']; 
    header("Content-type: required type"); 
    header("Content-Disposition: attachment; filename=$name"); 
    echo $content; 
    exit; 
    } 
    else{ 
    echo "Cannot download";} 

} 
?> 

아직 두 번째 문제를 해결할 수 없습니다.