Oracle BLOB column type
Posted 14 May 2010 - 03:18 PM
I have a column in the database as a type BLOB - and the model is limiting the content to 4000 characters. I changed that limit to 40000 just for grins so I could test a longer post, and I get
CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1461 OCIStmtExecute: ORA-01461: can bind a LONG value only for insert into a LONG column
So YII is thinking this is a LONG type, not a BLOB.
Any ideas ?
Posted 01 September 2011 - 11:12 PM
PDO OCI is interpreting your string as LONG, since it is a very large string.
I suggest you to use Yii DAO, since you cand bind your field with PDO::PARAM_LOB. Read here PDO Lobs
*PS: I am developing OCI-AR support for LOBs. I hope to publish it as soon as I can.
Posted 07 August 2013 - 05:06 AM
"CDbCommand failed to execute the SQL statement: ORA-01461"
I have tried with this code but the result is the same... Any suggestions?
$t = 'dc_conferme'; //var $file_name = $file->name; $file_type = $file->type; $file_size = $file->size; $file_contents = file_get_contents($file->tempName); // sql $sql="INSERT INTO ".$t." (file_name,file_size,file_type,ricevuta) VALUES(:file_name,:file_size,:file_type,:file_content)"; $connection = Yii::app()->db; $command=$connection->createCommand($sql); // bind params $command->bindParam(":file_name",$file_name,PDO::PARAM_STR); $command->bindParam(":file_type",$file_type,PDO::PARAM_STR); $command->bindParam(":file_size",$file_size,PDO::PARAM_STR); $command->bindParam(":file_content",$file_contents,PDO::PARAM_LOB); $command->execute();
Posted 26 October 2013 - 07:45 AM
I search it all around the net, finally I found a probably solution at Large Object.
I follow the example #2
<?php $db = new PDO('odbc:SAMPLE', 'db2inst1', 'ibmdb2'); $stmt = $db->prepare("insert into images (id, contenttype, imagedata) values (?, ?, ?)"); $id = get_new_id(); // some function to allocate a new ID // assume that we are running as part of a file upload form // You can find more information in the PHP documentation $fp = fopen($_FILES['file']['tmp_name'], 'rb'); $stmt->bindParam(1, $id); $stmt->bindParam(2, $_FILES['file']['type']); $stmt->bindParam(3, $fp, PDO::PARAM_LOB); $db->beginTransaction(); $stmt->execute(); $db->commit(); ?>
I get the db by
$db = Yii::app()->db->getPdoInstance()
$db = new PDO('odbc:SAMPLE', 'db2inst1', 'ibmdb2');
and other things are all the same.