From ba3c9d60aa367ec01771b4144051eb601c5355a4 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 26 Aug 2010 05:13:27 +1000 Subject: [PATCH] OSB Mod: Update to KH ORM for OSB. --- .../kohana/modules/orm/classes/kohana/orm.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/includes/kohana/modules/orm/classes/kohana/orm.php b/includes/kohana/modules/orm/classes/kohana/orm.php index d5ee716c..54fdd565 100644 --- a/includes/kohana/modules/orm/classes/kohana/orm.php +++ b/includes/kohana/modules/orm/classes/kohana/orm.php @@ -401,15 +401,19 @@ class Kohana_ORM { } elseif (array_key_exists($column, $this->_object)) { - $this->_object[$column] = $value; - - if (isset($this->_table_columns[$column])) + // Only record the change, if the value is actually changed + if ($this->_object[$column] !== $value) { - // Data has changed - $this->_changed[$column] = $column; + $this->_object[$column] = $value; - // Object is no longer saved - $this->_saved = FALSE; + if (isset($this->_table_columns[$column])) + { + // Data has changed + $this->_changed[$column] = $column; + + // Object is no longer saved + $this->_saved = FALSE; + } } } elseif (isset($this->_belongs_to[$column])) @@ -834,9 +838,11 @@ class Kohana_ORM { $data[$column] = $this->_object[$column] = ($format === TRUE) ? time() : date($format); } + // @todo move this OSB specific site_id processing elsewhere $query = DB::update($this->_table_name) ->set($data) ->where($this->_primary_key, '=', $this->pk()) + ->and_where('site_id','=',Config::siteid()) ->execute($this->_db); // Object has been saved @@ -853,6 +859,9 @@ class Kohana_ORM { $data[$column] = $this->_object[$column] = ($format === TRUE) ? time() : date($format); } + // @todo move this OSB specific site_id processing elsewhere + $data['site_id'] = Config::siteid(); + $result = DB::insert($this->_table_name) ->columns(array_keys($data)) ->values(array_values($data))