1、在php中实现查询CLOB类型的字段DETAIL
public function getProductClob($id) {
$db_str = ''XXX.XX.XX.XX:3306';//ip
$usename = 'root';//用户名
$pwd = '123456';//密码
$link = oci_connect($usename, $pwd, $db_str, 'UTF8');
if (!$link) {
$error = '';
exit($error);
}
$sql = "SELECT t.DETAIL as DETAIL FROM T_PRODUCT t WHERE PROD_ID={$id}";
$result = oci_parse($link, $sql);
oci_execute($result);
if ($result) {
while ($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_LOBS)) {
oci_free_statement($result);
oci_close($link);
return $row['DETAIL'];
}
}
oci_free_statement($result); //释放资源 释放关联于 Oracle 游标或语句的资源,该资源是作为 oci_parse() 的结果或者是从 Oracle 取得
oci_close($link); //关闭数据库连接
return '';
}
2、php查询mysql中的mediumtext(或TEXT)类型的数据
public function getProductDetailClob($id)
{
$host = 'xxx.xx.xx.xx:3306';
$usename = 'root';
$pwd = '123456';
$mysql_database='database';
$con = mysql_connect($host,$usename,$pwd);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($mysql_database,$con); //打开数据库
mysql_query("set names 'utf8'"); //数据库输出编码
// mysql_query("SETTEXTSIZE65536"); //设置TEXT类型最大值65536
$sql = "SELECT t.DETAIL as DETAIL FROM T_PRODUCT t WHERE PROD_ID={$id}";
$query=mysql_query($sql);
$result= mysql_fetch_row($query);
return $result;
}