We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PDO Oracle INSERT LOB

Hi,

I dig many google suggestion to find a working solution but I got nothing.

What is the right way to insert a file on a Oracle LOB column with PDO?

I'm always getting a data length of 0 for the content of the LOB in the database. I saw many forum suggesting to use RETURNING in the query with EMPTY_LOB(), even then my LOB is always empty. This is what I have right now (my code is customizable, I gave you just the minimum). I push on arrayOfBind in the same time that I build my variable. Every parameter is in the correct order. I can see my result in my database viewer but LOB always empty.

$sql = "INSERT INTO {$tableName} ({$strCol}) VALUES ({$strBind}) RETURNING {$fileAttr} INTO ?";

$stmt = $connection->prepare($sql);

foreach($arrayOfBind as $binding){
     $stmt->bindParam($binding[0], $binding[1], $binding[2]); 
}

$stmt->execute();
$stmt->commit();

I try too to insert an EMPTY_LOB() first and after than execute and UPDATE for the LOB, nothing different on the result. If I do stream_get_contents on my file, I saw the data. fileSize give me the correct lenght of the file. My other database columns are filled correctly. (size, mime, name)

Help will be appreciate.

Thanks

edited Apr '15

I try the two kinds of binding, question mark and :MYVAR, same result...

For your info my database info:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

PDO infos:

PDO support enabled

PDO drivers mysql, odbc, pgsql, ibm, oci

PDO Driver for OCI 8 and later enabled

I'm using PDO::PARAM_LOB for the BLOB binding