我在DB中有一个CLOB
类型的列,我无法在PHP中获取该值,因为它显示为
“resource id ='204'type ='”oci8 descriptor“'”。
我的适配器代码:
$this->_db->fetchRow(
$this->_db->select()
->from(self::TABLE_NAME, array(
'BODY'
))
答案 0 :(得分:1)
这在The Underground PHP and Oracle Manual,第234页“获取LOB”中有所介绍。以下是该页面的示例:
<?php
$c = oci_connect('hr', 'welcome', 'localhost/XE');
$myblobid = 123;
$query = 'select blobdata from mybtab where blobid = :myblobid';
$s = oci_parse($c, $query);
oci_bind_by_name($s, ':myblobid', $myblobid);
oci_execute($s);
$arr = oci_fetch_array($s, OCI_ASSOC);
if (is_object($arr['BLOBDATA'])) { // protect against a NULL LOB
$data = $arr['BLOBDATA']->load();
$arr['BLOBDATA']->free();
echo $data;
}
?>
我建议您自己阅读手册页,因为有关于避免内存泄漏和将LOB数据作为字符串返回的重要建议。