Home > php教程 > php手册 > body text

PHP处理Oracle的CLOB实例

WBOY
Release: 2016-06-06 20:18:11
Original
1115 people have browsed it

这篇文章主要介绍了PHP处理Oracle的CLOB的方法,以实例形式简单讲述了写入数据与读取数据的方法,需要的朋友可以参考下

本文实例简述了PHP处理Oracle的CLOB的方法。分享给大家供大家参考。具体方法如下:

1. 写入数据
 
在使用PDO的预处理方法时,如果使用bindParam()等而不指定字段的数据类型或使用execute(),PDO都会默认为string类型,,并且限定一个默认长度

所以在存clob类型字段时必须使用bindParam()或bindValue()等,并指定字符串长度,例如:

复制代码 代码如下:

$pdo -> bindParam(':clobData', $clobData, PDO::PARAM_STR,strlen($clobData));

2. 读取数据

PDO取出的CLOB字段值在该字段不为空时是资源标识符,为空时为空字符串,取数据方法如下

复制代码 代码如下:

$arr = $pdo -> fetch();
is_resource($arr['clob']) && $arr['clob'] =stream_get_contents($arr['clob']);

希望本文所述对大家的PHP程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!