setLoggableFieldsForStore(); if($this->_cryptedFields){ foreach($this->_cryptedFields as $field){ if(isset($this->$field)){ $this->$field = vmCrypt::encrypt($this->$field); } } } $this->storeParams(); $tblKey = $this->_tbl_key; $pKey = $this->_pkey; $res = false; if($tblKey == $pKey){ //vmdebug('VmTableData '.get_class($this). ' need not to be a vmtabledata $tblKey == $pKey'); 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(); } } 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) ) { $res = true; } } if($res){ $returnCode = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $p = $this->$tblKey; $returnCode = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); if($returnCode and !empty($this->_hashName)){ $oldH= $this->{$this->_hashName}; if($p!=$this->$tblKey and !in_array($tblKey,$this->_omittedHashFields)){ $this->hashEntry(); $ok = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); vmdebug('Updated entry with correct hash ',$this->_tbl_key,$p,$this->$tblKey,$oldH,$this->{$this->_hashName}); } } } //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; } } }