如何使用php PDO从mssql(数据库)中检索基于二进制的图像?

时间:2014-04-18 21:20:36

标签: php database pdo

<?php
    $sql = utf8_decode("SELECT Photo,Code_Musicien FROM Musicien WHERE Code_Musicien=?");

    try {
      $stmt = $db->prepare($sql);
      $stmt->execute(array($_GET['image']));
      $stmt->bindColumn(1, $lob, PDO::PARAM_LOB);
    } catch (PDOException $e) {
      echo "Data could not be retrieved from the database." . $e->getMessage();
    }

    $stmt->fetch(PDO::FETCH_BOUND);
    if (is_string($lob)) {
       $lob = fopen('data://image/jpeg;base64,' . base64_encode($lob), 'r');
    }

fpassthru($lob);

&GT;

0 个答案:

没有答案