note 29916 deleted from function.ocibindbyname by sixd
| From: | sixd@php.net | Date: | Wed, 20 Nov 2013 19:48:24 +0000 |
| Subject: | note 29916 deleted from function.ocibindbyname by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197590@lists.php.net to get a copy of this message | ||
Note Submitter: aidan.peiser at shopsmart dot com
----
I have made two function to add and update a table with a CLOB field in it.all you have to do is
pass the correct data through the function and it should work...
<?php
/*the table sql looks like this:
create table MY_PAGE (pageid varchar2(20),
pagename varchar2(50),
pageurl varchar2(100),
edited date,
bodymessage clob);
create sequence mypage_sequence minvalue 1 nocache;
*/
function updatePageData($select,$pagename,$pageurl,$document) {
global $conn;
$current_time=date("YmdHis");
$sql = "update MY_PAGE set PAGENAME='$pagename',
PAGEURL='$pageurl',
EDITED=TO_DATE('$current_time','YYYYMMDDHH24MISS'), BODYMESSAGE = EMPTY_CLOB()
WHERE PAGEID = '$select' returning BODYMESSAGE into :bodymessage";
echo $sql;
$stmt = OCIParse($conn,$sql);
$lob = OCINewDescriptor($conn,OCI_D_LOB);
OCIBindByName($stmt,":bodymessage",&$lob,-1,OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$lob->save($document);
$lob->free();
OCIFreeStatement($stmt);
if(OCICommit($conn)){
return true;
}else{
return false;
}
}
function insertPageData($pagename,$pageurl,$document) {
global $conn;
$current_time=date("YmdHis");
$query = "insert into MY_PAGE (PAGEID, PAGENAME, PAGEURL, EDITED, BODYMESSAGE)
values (mypage_sequence.nextval,
'$pagename',
'$pageurl',
TO_DATE('$current_time','YYYYMMDDHH24MISS'),
empty_clob()) returning BODYMESSAGE into :bodymessage";
$stmt = OCIParse($conn, $query);
$clob1 = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName ($stmt, ":bodymessage", &$clob1, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob1->save ($document);
if(OCICommit($conn)){
echo "data inserted";
}else{
echo "unable to insert data";
}
}
?>