PHP handles CLOB instances of Oracle
- 2021-07-24 10:22:28
- OfStack
In this paper, the method of PHP processing CLOB of Oracle is briefly described with examples. Share it for your reference. The specific methods are as follows:
1. Write data
When using the preprocessing method of PDO, if bindParam () and so on are used without specifying the data type of the field or execute (), PDO will default to the string type and be limited to 1 default length
So you must use bindParam () or bindValue () and so on when storing clob type fields, and specify the string length, for example:
$pdo -> bindParam(':clobData', $clobData, PDO::PARAM_STR,strlen($clobData));
Step 2 Read the data
The value of CLOB field 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 taking data is as follows
$arr = $pdo -> fetch();
is_resource($arr['clob']) && $arr['clob'] =stream_get_contents($arr['clob']);
I hope this article is helpful to everyone's PHP programming.