OSB Mod: Update to KH ORM for OSB.

This commit is contained in:
Deon George 2010-08-26 05:13:27 +10:00
parent 6fb7d0035a
commit ba3c9d60aa

View File

@ -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))