Minor improvements to blobs
This commit is contained in:
@@ -104,6 +104,17 @@ abstract class ORMOSB extends ORM {
|
||||
$model->$field = serialize($value);
|
||||
}
|
||||
|
||||
public function __get($column) {
|
||||
// If the column is a blob, we'll decode it automatically
|
||||
if (array_key_exists($column,$this->_object) AND $this->_table_columns[$column]['data_type'] == 'blob' AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert'])) {
|
||||
|
||||
$this->_object[$column] = $this->blob($this->_object[$column]);
|
||||
$this->_table_columns[$column]['auto_convert'] = TRUE;
|
||||
}
|
||||
|
||||
return parent::__get($column);
|
||||
}
|
||||
|
||||
public function save(Validation $validation = NULL) {
|
||||
// Find any fields that have changed, and that are blobs, and encode them.
|
||||
if ($this->_changed)
|
||||
@@ -121,7 +132,7 @@ abstract class ORMOSB extends ORM {
|
||||
/**
|
||||
* Retrieve and Store DB BLOB data.
|
||||
*/
|
||||
protected function blob($data,$set=FALSE) {
|
||||
private function blob($data,$set=FALSE) {
|
||||
return $set ? gzcompress(serialize($data)) : unserialize(gzuncompress($data));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user