/** * Overload setting offsets to insert or update the database values as * changes occur. * * @param string array key * @param mixed new value * @return mixed */ public function offsetSet($key, $value) { if (!$this->offsetExists($key)) { // Insert a new value DB::insert($this->_database_table, array('group_name', 'config_key', 'config_value'))->values(array($this->_configuration_group, $key, serialize($value)))->execute($this->_database_instance); } elseif ($this->offsetGet($key) !== $value) { // Update the value DB::update($this->_database_table)->value('config_value', serialize($value))->where('group_name', '=', $this->_configuration_group)->where('config_key', '=', $key)->execute($this->_database_instance); } return parent::offsetSet($key, $value); }