I am trying to insert image file.
For example, I can insert multiple transaction document(image file) for a single transaction. When I insert the first transaction document, It works fine.
But for the second time, It gives an error:
Fatal error: Call to a member function savefile() on a non-object in D:\FTP\LocalUser\ftpweb\library\Transaction.php on line 203
I tried to debug it by var_dump($lob).
It gives: object(OCI-Lob)#13 (1) { => resource(44) of type (oci8 descriptor) }
But it says, $lob a non object. I am not getting what's going on here.
Please can anyone help me to find out the solutions.
Here's the code where I have used a ocinewdescriptor:
Code: Select all
function fnTransactionDocument($mode=NULL){
$Sql="BEGIN PKG_TRANSACTION.PR_TRANSACTION_DOCUMENT( ";
$Sql.="'$mode'";//mode CHAR(1)
//serial_no VARCHAR2(20)
$Sql.=",";
$Sql.=$this->isPropertySet("serial_no")?"'".$this->getProperty("serial_no")."'":"NULL";
//member_cd VARCHAR2(20)
$Sql.=",";
$Sql.=$this->isPropertySet("transaction_cd")?"'".$this->getProperty("transaction_cd")."'":"NULL";
//document_type_cd VARCHAR2(20)
$Sql.=",";
$Sql.=$this->isPropertySet("document_type_cd")?"'".$this->getProperty("document_type_cd")."'":"NULL";
//document_name VARCHAR2(20)
$Sql.=",";
$Sql.=$this->isPropertySet("document_name")?"'".$this->getProperty("document_name")."'":"NULL";
//document_id
$Sql.=",";
$Sql.=$this->isPropertySet("document_id")?"'".$this->getProperty("document_id")."'":"NULL";
//document_data BLOB
$Sql.=",";
$Sql.=":document_data";
//document_mime_type VARCHAR(20)
$Sql.=",";
$Sql.=$this->isPropertySet("document_mime_type")?"'".$this->getProperty("document_mime_type")."'":"NULL";
//status CHAR(1)
$Sql.=",";
$Sql.=$this->isPropertySet("status")?"'".$this->getProperty("status")."'":"'E'";
//entered_by VARCHAR2(20)
$Sql.=",";
$Sql.=$this->isPropertySet("entered_by")?"'".$this->getProperty("entered_by")."'":"'".$_SESSION."'";
//printed
$Sql.=",";
$Sql.=$this->isPropertySet("printed")?"'".$this->getProperty("printed")."'":"'N'";
$Sql.="); END;";
//print($Sql); die();
$lob = OCINewDescriptor($this->connection, OCI_D_LOB);
$stmt = OCIParse($this->connection, $Sql);
OCIBindByName($stmt, ":document_data", $lob, -1, OCI_B_BLOB);
if(!OCIExecute($stmt, OCI_DEFAULT))
return false;
if (!$lob->savefile($this->getProperty('document_data')))
return false;
if(!OCICommit($this->connection))
return false;
return true;
//return true;
}
Ratna