setLoggableFieldsForStore(); $this->storeParams(); $tblKey = $this->_tbl_key; $pKey = $this->_pkey; if($tblKey == $pKey){ //vmdebug('VmTableData '.get_class($this). ' need not to be a vmtabledata $tblKey == $pKey'); $res = false; if(!empty($this->$tblKey)){ $_qry = 'SELECT `'.$this->_tbl_key.'` ' . 'FROM `'.$this->_tbl.'` ' . 'WHERE `'.$this->_tbl_key.'` = "' . $this->$tblKey.'" '; $this->_db->setQuery($_qry); $res = $this->_db->loadResult(); } if($res){ $returnCode = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $returnCode = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); } } else { if(!empty($this->$pKey)){ $_qry = 'SELECT `'.$this->_tbl_key.'` ' . 'FROM `'.$this->_tbl.'` ' . 'WHERE `'.$this->_pkey.'` = "' . $this->$pKey.'" '; $this->_db->setQuery($_qry); //Yes, overwriting $this->$tblKey is correct ! $this->$tblKey = $this->_db->loadResult(); } if ( !empty($this->$tblKey) ) { $returnCode = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $returnCode = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); } } //reset Params if(isset($this->_tmpParams) and is_array($this->_tmpParams)){ foreach($this->_tmpParams as $k => $v){ $this->$k = $v; } } $this->_tmpParams = false; if (!$returnCode) { vmError(get_class($this) . '::store failed - ' . $this->_db->getErrorMsg()); return false; } else { return true; } } }