/** * Extends the default save method. * Saves only if this kind of entry do not exists. * * @return bool */ public function save() { $oDb = oxDb::getDb(); $sQ = "select 1 from oxobject2group where oxgroupsid = " . $oDb->quote($this->oxobject2group__oxgroupsid->value); $sQ .= " and oxobjectid = " . $oDb->quote($this->oxobject2group__oxobjectid->value); // does not exist if (!$oDb->getOne($sQ, false, false)) { return parent::save(); } }
/** * Extends the default save method. * Saves only if this kind of entry do not exists. * * @throws DatabaseException * * @return bool */ public function save() { try { return parent::save(); } catch (\OxidEsales\EshopCommunity\Core\Exception\DatabaseException $exception) { /** * The table oxobject2group has an UNIQUE index on (OXGROUPSID, OXOBJECTID, OXSHOPID) * If there is a DatabaseException and the exception code is 1062 i.e. "Duplicate entry", * the exception will be discarded and the record will not be inserted. */ if ($exception->getCode() != '1062') { throw $exception; } } }
/** * Saves order article object. If saving succeded - updates * article stock information if oxOrderArticle::isNewOrderItem() * returns TRUE. Returns saving status * * @return bool */ public function save() { // ordered articles if (($blSave = parent::save()) && $this->isNewOrderItem()) { $myConfig = $this->getConfig(); if ($myConfig->getConfigParam('blUseStock') && $myConfig->getConfigParam('blPsBasketReservationEnabled')) { $this->getSession()->getBasketReservations()->commitArticleReservation($this->oxorderarticles__oxartid->value, $this->oxorderarticles__oxamount->value); } else { $this->updateArticleStock($this->oxorderarticles__oxamount->value * -1, $myConfig->getConfigParam('blAllowNegativeStock')); } // seting downloadable products article files $this->_setOrderFiles(); // marking object as "non new" disable further stock changes $this->setIsNewOrderItem(false); } return $blSave; }
/** * Save this Object to database, insert or update as needed. * * @return mixed */ public function save() { if (!$this->oxrecommlists__oxtitle->value) { throw oxNew("oxObjectException", 'EXCEPTION_RECOMMLIST_NOTITLE'); } return parent::save(); }
/** * Create object 2 object connection in databse * * @param array $aData db fields and values * @param string $sObj2ObjTable table name */ public function createObj2Obj($aData, $sObj2ObjTable) { if (empty($aData)) { return; } $iCnt = count($aData); for ($i = 0; $i < $iCnt; $i++) { $oObj = new oxBase(); $oObj->init($sObj2ObjTable); if ($iCnt < 2) { $aObj = $aData[$i]; } else { $aObj = $aData; } foreach ($aObj as $sKey => $sValue) { $sField = $sObj2ObjTable . "__" . $sKey; $oObj->{$sField} = new oxField($sValue, oxField::T_RAW); } $oObj->save(); } }
/** * Saves (updates) user object data information in DB. Return true on success. * * @return bool */ public function save() { $myConfig = oxRegistry::getConfig(); $blAddRemark = false; if ($this->oxuser__oxpassword->value && $this->oxuser__oxregister->value < 1) { $blAddRemark = true; //save oxregister value $this->oxuser__oxregister = new oxField(date('Y-m-d H:i:s'), oxField::T_RAW); } // setting user rights $this->oxuser__oxrights = new oxField($this->_getUserRights(), oxField::T_RAW); // processing birth date which came from output as array if (is_array($this->oxuser__oxbirthdate->value)) { $this->oxuser__oxbirthdate = new oxField($this->convertBirthday($this->oxuser__oxbirthdate->value), oxField::T_RAW); } $blRet = parent::save(); //add registered remark if ($blAddRemark && $blRet) { $oRemark = oxNew('oxremark'); $oRemark->oxremark__oxtext = new oxField(oxRegistry::getLang()->translateString('usrRegistered', null, true), oxField::T_RAW); $oRemark->oxremark__oxtype = new oxField('r', oxField::T_RAW); $oRemark->oxremark__oxparentid = new oxField($this->getId(), oxField::T_RAW); $oRemark->save(); } return $blRet; }
/** * Saves (updates) user object data information in DB. Return true on success. * * @return bool */ public function save() { $myConfig = oxConfig::getInstance(); $blAddRemark = false; if ($this->oxuser__oxpassword->value && $this->oxuser__oxregister->value < 1) { $blAddRemark = true; //save oxregister value $this->oxuser__oxregister = new oxField(date('Y-m-d H:i:s'), oxField::T_RAW); } // setting user rights $this->oxuser__oxrights = new oxField($this->_getUserRights(), oxField::T_RAW); // processing birth date which came from output as array if (is_array($this->oxuser__oxbirthdate->value)) { $this->oxuser__oxbirthdate = new oxField($this->convertBirthday($this->oxuser__oxbirthdate->value), oxField::T_RAW); } // checking if user Facebook ID should be updated if ($myConfig->getConfigParam("bl_showFbConnect")) { $oFb = oxFb::getInstance(); if ($oFb->isConnected() && $oFb->getUser()) { $this->oxuser__oxfbid = new oxField($oFb->getUser()); } } $blRet = parent::save(); //add registered remark if ($blAddRemark && $blRet) { $oRemark = oxNew('oxremark'); $oRemark->oxremark__oxtext = new oxField(oxLang::getInstance()->translateString('usrRegistered'), oxField::T_RAW); $oRemark->oxremark__oxtype = new oxField('r', oxField::T_RAW); $oRemark->oxremark__oxparentid = new oxField($this->getId(), oxField::T_RAW); $oRemark->save(); } return $blRet; }
/** * Updates/inserts order object and related info to DB * * @return null */ public function save() { if ($blSave = parent::save()) { // saving order articles $oOrderArticles = $this->getOrderArticles(); if ($oOrderArticles && count($oOrderArticles) > 0) { foreach ($oOrderArticles as $oOrderArticle) { $oOrderArticle->save(); } } } return $blSave; }