Habari\InfoRecords::commit PHP Method

commit() public method

If this function is not called, then the options will not be written.
public commit ( mixed $metadata_key = null ) : boolean
$metadata_key mixed (optional) Key to use when writing info data.
return boolean True if the commit succeeded.
    public function commit($metadata_key = null)
    {
        if (isset($metadata_key)) {
            $this->_key_value = $metadata_key;
        }
        // If the info is not already loaded, and the key value is empty,
        // then we don't have enough info to do the commit
        if (!$this->_loaded && empty($this->_key_value)) {
            return false;
        }
        // If there were no changes, do nothing and succeed.  Yay!
        if (!$this->_dirty) {
            return true;
        }
        foreach ((array) $this->__inforecord_array as $name => $record) {
            if (isset($record['changed']) && $record['changed']) {
                $value = $record['value'];
                if (is_array($value) || is_object($value)) {
                    $result = DB::update($this->_table_name, array($this->_key_name => $this->_key_value, 'name' => $name, 'value' => serialize($value), 'type' => 1), array('name' => $name, $this->_key_name => $this->_key_value));
                } else {
                    $result = DB::update($this->_table_name, array($this->_key_name => $this->_key_value, 'name' => $name, 'value' => $value, 'type' => 0), array('name' => $name, $this->_key_name => $this->_key_value));
                }
                if (Error::is_error($result)) {
                    $result->out();
                }
                $this->__inforecord_array[$name] = array('value' => $value);
            }
        }
        $this->_dirty = false;
        return true;
    }