PHP processes Oracle CLOB instances and oracleclob instances
This example briefly describes how PHP processes Oracle CLOB. Share it with you for your reference. The specific method is as follows:
1. Write Data
When PDO preprocessing is used, if bindParam () is used without specifying the Data Type of the field or execute (), PDO defaults to the string type and limits a default length.
Therefore, bindParam () or bindValue () must be used to store clob fields and specify the string length. For example:
Copy codeThe 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 this field is not empty. If it is null, It is a Null String. The data retrieval method is as follows:
Copy codeThe Code is as follows: $ arr = $ pdo-> fetch ();
Is_resource ($ arr ['clob']) & $ arr ['clob'] = stream_get_contents ($ arr ['clob']);
I hope this article will help you with PHP programming.
Why does php always prompt errors when operating oracle's clob type?
Dude, I also encountered this problem. I solved it with the same solution.
How does php read the clob field?
Write Data
When PDO preprocessing is used, if bindParam () is used without specifying the Data Type of the field or execute (), PDO defaults to the string type and limits a default length.
Therefore, bindParam () or bindValue () must be used to store clob fields and specify the string length, for example, $ pdo-> bindParam (': clobdata', $ clobData, PDO:: PARAM_STR, strlen ($ clobData ));
Read data
The CLOB field value retrieved by PDO is a resource identifier when this field is not empty. If it is null, It is a Null String. The data retrieval method is as follows:
$ Arr = $ pdo-> fetch ();
Is_resource ($ arr ['clob']) & $ arr ['clob'] = stream_get_contents ($ arr ['clob']);
Hope to help you