4

使用 MySQL,我可以在 TEXT 列中存储大块文本,就像我使用任何其他列类型一样,没有问题。

似乎当我尝试在 Oracle 上对 CLOB 执行相同操作时,出现错误。

这是我要拉的地方:

<?php
$comments = 'SELECT q2_other, q4_comments, q9_describe, q10, q11_comments, q12_describe, additional_comments FROM exit_responses
             WHERE sdate BETWEEN \'' . $start . '\'
             AND \'' . $end . '\'';

$comments_results = oci_parse($conn, $comments);
oci_execute($comments_results);

while($row = oci_fetch_assoc($comments_results)){
  if($row['Q2_OTHER'] != null){
  echo '<div class="response">';
    echo '<div class="info-bar">';
      echo '<h5 class="date">' , date('F j, Y',strtotime($row['SDATE'])) , '</h5>';
      echo ($_GET['names'] == 1) ? '<h5 class="name">' . $row['f_name'] . ' ' . $row['l_name'] . ' - ' . $row['title'] . ' - ' . $row['emp_type'] . '</h5>' : '';
      echo '<div class="clear"></div>';
    echo '</div>';
    echo '<div class="comments">' , $row['q2_other'] , '</div>';
    echo '<div class="clear"></div>';
  echo '</div>';
  }
}
?>

...这是我在 while() 循环中尝试 print_r() $row 时得到的结果:

[Q2_OTHER] => OCI-Lob Object
        (
            [descriptor] => Resource id #17
        )

...(连同查询中的其他列)

我需要对 CLOBS 做些什么特别的事情,或者我的语法有点不对劲。

谢谢 :)

4

2 回答 2

5

对于 LOB 列,OCI 将返回 OCI-Lob 对象,您必须在该对象上调用load()read(int bytes)获取内容:

$clob_contents = $row['Q2_OTHER']->load();
于 2010-11-03T22:13:33.430 回答
3

或者您可以使用 OCI_RETURN_LOBS 标志 $row = oci_fetch_array($connection_id, OCI_ASSOC | OCI_RETURN_LOBS)像 VARCHAR2 一样获取 CLOB:

$row['clob_field_name']

于 2011-02-03T09:18:05.670 回答