如何使用PHP在Oracle中显示Blob图像

时间:2019-01-25 06:36:44

标签: php oracle11g blob

我要显示数据库(Oracle)中的图像(BLOB)。如果找不到图像,那么我要显示一些默认图像。

$row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS) 

找到图像后工作正常。

我也尝试过

$row = oci_fetch_row($stmt, OCI_ASSOC+OCI_RETURN_NULLS) 

但它会重播为假。

$query = 'SELECT SEEK_PICTURE FROM JOB_SEEKER WHERE SEEK_ID = :MYBLOBID';
$stmt = oci_parse ($db, $query);
oci_bind_by_name($stmt, ':MYBLOBID', $id);
oci_execute($stmt);
$row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS);

if (!$row) {
?> 

    <img id="image" src="images/default.png">

<?php
}            
else { 
    $result = $row['SEEK_PICTURE']->load();
?>

    <img id="image" src="data:image/jpeg;base64,<?php echo base64_encode($result); ?>"/>

<?php 
}   
?>

0 个答案:

没有答案