The code below is what you need to insert data into clobs:
$DBlink = ocilogon($DBUser,$DBPwd,$DBName); $Clob = OCINewDescriptor($DBlink, OCI_D_LOB); $query = "INSERT INTO TableName (ContentID, Content) VALUES ($NewID, EMPTY_CLOB()) returning Content into :THE_CLOB"; $DBresult = ociparse($DBlink, $query); OCIBindByName($DBresult, ":THE_CLOB", &$Clob, -1, OCI_B_CLOB); OCIExecute($DBresult, OCI_DEFAULT); $Clob->save($NewContent); if(OCICommit($DBlink)){ $result = true; } else{ $result = false; } OCILogOff ($DBlink);
To update CLOB's:
$query = "UPDATE TableName SET Content = EMPTY_CLOB() WHERE ContentID = $ID returning Content into :THE_CLOB";
$DBresult = ociparse($DBlink, $query);
$Clob = OCINewDescriptor($DBlink, OCI_D_LOB);
OCIBindByName($DBresult, ":THE_CLOB", &$Clob, -1, OCI_B_CLOB);
OCIExecute($DBresult, OCI_DEFAULT);
$Clob->save($NewContent);
if(OCICommit($this->DBlink)){ $this->resultado = true; } else{ $this->resultado = false; }
To read CLOBs:
$query = "SELECT Content FROM TableName WHERE ContentID = $ID"; $stmt=OCIParse($DBlink,$query); OCIExecute($stmt,OCI_DEFAULT); $result = array(); $x=0; while(OCIFetch($stmt)){ $ncols=OCINumCols($stmt); $result[$x] = array(); for($i=1,$j=0;$i<=$ncols;$i++,$j++){ $column_name=OCIColumnName($stmt,$i); if(is_object($tmp=OCIResult($stmt,$i))&&OCIColumnType($stmt,$i)=='CLOB'){ $column_value=$tmp->load(); }else{ $column_value=$tmp; } $result[$x][$j] = $column_value; } $x++; } OCICommit($DBlink);
It returns a bidimensional array ($result) containing CLOB's content
It's a little bit hard to understand because I'm using all this code inside a class I made to create all the queries, I had to change some codes and maybe it contains some errors, but I guess you can get the idea to manipulate CLOBs with this codes.
Jadiel Flores ------------------------- http://www.abargon.com jflores@abargon.com (52-55) 52-29-80-34
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php