Home  >  Article  >  Backend Development  >  PHP handles Oracle's CLOB instance, oracleclob instance_PHP tutorial

PHP handles Oracle's CLOB instance, oracleclob instance_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:15:291181browse

PHP handles Oracle's CLOB instance, oracleclob instance

The example in this article briefly describes how PHP handles Oracle's CLOB. Share it with everyone for your reference. The specific method is as follows:

1. Write data

When using PDO's preprocessing method, if you use bindParam(), etc. without specifying the data type of the field or use execute(), PDO will default to string type and limit a default length

So when storing clob type fields, you must use bindParam() or bindValue(), etc., and specify the string length, for example:

Copy code The code is as follows:
$pdo -> bindParam(':clobData', $clobData, PDO::PARAM_STR,strlen($clobData ));

2. Read data

The CLOB field value retrieved by PDO is a resource identifier when the field is not empty, and an empty string when it is empty. The method of obtaining data is as follows

Copy code The code is as follows:
$arr = $pdo -> fetch();
is_resource($arr['clob']) && $arr['clob'] =stream_get_contents($arr['clob']);

I hope this article will be helpful to everyone’s PHP programming design.

Why does PHP always prompt an error when operating Oracle's clob type?

Brother, I also encountered such a problem, please help me solve it and let me know if it is solved

How to read clob field in php

Writing data
When using the preprocessing method of PDO, if you use bindParam(), etc. without specifying the data type of the field or using execute(), PDO will default to the string type and limit a default length
so When storing clob type fields, you must use bindParam() or bindValue(), etc., and specify the string length, for example $pdo -> bindParam(':clobData', $clobData, PDO::PARAM_STR,strlen($clobData)) ;

Read data
The CLOB field value taken out by PDO is a resource identifier when the field is not empty, and an empty string when it is empty. The method of getting the data is as follows
$arr = $ pdo -> fetch();
is_resource($arr['clob']) && $arr['clob'] =stream_get_contents($arr['clob']);

Hope this helps To you

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/904919.htmlTechArticlePHP handles Oracle's CLOB instance, oracleclob instance. This example briefly describes how PHP handles Oracle's CLOB. Share it with everyone for your reference. The specific method is as follows: 1. Write data using...
Statement:
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