From 59760433156b959878f7473e8a8f64d7819d92e4 Mon Sep 17 00:00:00 2001 From: bermiferrer Date: Sun, 6 Apr 2008 23:40:09 +0000 Subject: [PATCH] Fixing binary null files on postgresql git-svn-id: http://svn.akelos.org/trunk@548 a2fa5c27-f921-0410-a72c-bf682d381be0 --- lib/AkActiveRecord.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/AkActiveRecord.php b/lib/AkActiveRecord.php index 0526072..46027df 100644 --- a/lib/AkActiveRecord.php +++ b/lib/AkActiveRecord.php @@ -3176,7 +3176,7 @@ class AkActiveRecord extends AkAssociatedActiveRecord case 'binary': if($this->_getDatabaseType() == 'postgre'){ - $result = " '".$this->_db->escape_blob($value)."'::bytea "; + $result = is_null($value) ? 'null::bytea ' : " '".$this->_db->escape_blob($value)."'::bytea "; }else{ $result = is_null($value) ? 'null' : ($add_quotes ? $this->_db->quote_string($value) : $value); } @@ -3234,7 +3234,8 @@ class AkActiveRecord extends AkAssociatedActiveRecord }elseif (!empty($value) && 'datetime' == $column_type && substr($value,0,10) == '0000-00-00'){ return null; }elseif ('binary' == $column_type && $this->_getDatabaseType() == 'postgre'){ - return $this->_db->unescape_blob($value); + $value = $this->_db->unescape_blob($value); + $value = empty($value) || trim($value) == 'null' ? null : $value; } } } -- 2.11.4.GIT