terry terry Tue Sep 13 09:13:32 -0400 2011

Subject: issue about blob type of oracle

table "chapter_content" constructor:
id char,
content BLOB

then

I use the statements
"
$chapter_content= ChapterContent::find('first',array('select'=>'id,content'));
var_dump($chapter_content->content);
"

finally I get the result:
string(15) "Resource id #23"

How do I get the data of content?


Clay vanSchalkwijk Tue Sep 13 10:41:19 -0400 2011

We don't currently have built-in support for BLOB or CLOB yet and you would need to write a getter and setter with the SQL query in it.

terry terry Tue Sep 13 10:59:57 -0400 2011

How do I get the database connection, and How do I handle this?

Can you give me an example?

Thanks!

Clay vanSchalkwijk Tue Sep 13 11:33:11 -0400 2011
 1 public function get_myfield()
 2 {
 3   $db = self::connection()->connection;
 4   $stmt = $db->prepare( 'select myfield from my_table where id = ?' );
 5   $stmt->execute( array( $this->id ) );
 6   $row = $stmt->fetch();
 7   $myfield = stream_get_contents( $row[0] );
 8   return $myfield;
 9 }  

Here is a sample getter. You can just pull the PDO connection out from the model and go from there. Here is a good resource on LOB with PDO:

http://wezfurlong.org/blog/2005/oct/lob-support-added-to-pdo-oci-in-php-5-1-cvs-finally/
http://www.phpactiverecord.org/docs/ActiveRecord/Model#method__get
http://www.phpactiverecord.org/docs/ActiveRecord/Model#method__set

terry terry Wed Sep 14 00:28:35 -0400 2011

Thanks very much!

Ahmed Alsamawi Fri Dec 04 14:01:30 -0500 2015

I ran through the same issue and I've applied a patch to my local version feel free to fix it on your side as well:

Edit Column.php file: