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.
How do I get the database connection, and How do I handle this?
Can you give me an example?
Thanks!
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
Thanks very much!
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:
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?