/** * Inserts a new row if id is zero or updates an existing row in the database table * * Can be overloaded/supplemented by the child class * @return null|string null if successful otherwise returns and error message */ public function store($updateNulls = false) { global $AppUI; $this->w2PTrimAll(); $msg = $this->check(); if (is_array($msg) && count($msg) || !is_array($msg) && strlen($msg)) { return get_class($this) . '::store-check failed ' . $msg; } $k = $this->_tbl_key; if ($this->{$k}) { $store_type = 'update'; $q = new w2p_Database_Query(); $ret = $q->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); $q->clear(); } else { $store_type = 'add'; $q = new w2p_Database_Query(); $ret = $q->insertObject($this->_tbl, $this, $this->_tbl_key); $q->clear(); } if ($ret) { // only record history if an update or insert actually occurs. addHistory($this->_tbl, $this->{$k}, $store_type, $AppUI->_('ACTION') . ': ' . $store_type . ' ' . $AppUI->_('TABLE') . ': ' . $this->_tbl . ' ' . $AppUI->_('ID') . ': ' . $this->{$k}); } return !$ret ? get_class($this) . '::store failed ' . db_error() : null; }
public function updateObject($table, &$object, $keyName, $updateNulls = true) { parent::updateObject($table, $object, $keyName, $updateNulls); }