note 29916 added to function.ocibindbyname
| From: | aidan dot peiser at rack1 dot php dot net | Date: | Fri, 28 Feb 2003 17:06:41 +0000 |
| Subject: | note 29916 added to function.ocibindbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44667@lists.php.net to get a copy of this message | ||
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";
}
}
?>
--
http://www.php.net/manual/en/function.ocibindbyname.php
http://master.php.net/manage/user-notes.php?action=edit+29916
http://master.php.net/manage/user-notes.php?action=delete+29916
http://master.php.net/manage/user-notes.php?action=reject+29916