Yii Framework Forum: Oracle BLOB column type - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Oracle BLOB column type Rate Topic: -----

#1 User is offline   jwheat 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 13-May 10

Posted 14 May 2010 - 03:18 PM

I'm building a content submission form using the nh-ckeditor extension for the content body area. I'm using Oracle with the pdo_oci driver, and its been working great so far.

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 ?


#2 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 375
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

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.
Yes, It Is!

#3 User is offline   ilbassa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 27-May 13

Posted 07 August 2013 - 05:06 AM

I have the same error while uploading PDF or JPG file into a BLOB column
"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';
			$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) 
			$connection = Yii::app()->db;
			// bind params


#4 User is offline   Breno Mayder 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 85
  • Joined: 15-September 10
  • Location:Belo Horizonte - Brasil

Posted 18 October 2013 - 08:13 AM

Someone managed to make sending a BLOB to Oracle?
Breno Mayder
Posted Image

#5 User is offline   because of love 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-June 13

Posted 26 October 2013 - 07:45 AM

I have worked it out.
I search it all around the net, finally I found a probably solution at Large Object.
I follow the example #2
$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);


I get the db by
$db = Yii::app()->db->getPdoInstance() 

instead by
$db = new PDO('odbc:SAMPLE', 'db2inst1', 'ibmdb2');

and other things are all the same.

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users