當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ActiveRecord::update方法代碼示例

本文整理匯總了PHP中yii\db\ActiveRecord::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP ActiveRecord::update方法的具體用法?PHP ActiveRecord::update怎麽用?PHP ActiveRecord::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\db\ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::update方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * @inheritdoc
  */
 public function update($runValidation = true, $attributeNames = null)
 {
     $this->trigger(static::EVENT_AFTER_UPDATE_TRANSACTION);
     return parent::update($runValidation, $attributeNames);
 }
開發者ID:ancor-dev,項目名稱:yii2-model,代碼行數:8,代碼來源:ActiveRecord.php

示例2: update

    public function update($runValidation = true, $attributeNames = null){
        $this->image = UploadedFile::getInstance($this->user0, 'profile_pic');

        if(!parent::validate())
            return false;

        if($this->image instanceof  UploadedFile){

            if(!getimagesize($this->image->tempName)){
                $this->addError('image','Please Upload a valid Image');
                return false;
            }

            Auction::info('Image Upload Event Triggered');
            $this->trigger(Events::UPLOAD_IMAGE);

            parent::update(false);
            $this->user0->profile_pic = $this->image;
        }
        else{
            $this->user0->profile_pic = $this->user0->oldAttributes['profile_pic'];
        }

        if($this->user0->save(false)) {
            Auction::info('Dealer is successsfully Updated');
            return true;
        }else{
            Auction::infoLog('Dealer is not updated Due to following validation Errors',$this->user0->getErrors());
            return false;
        }
    }
開發者ID:harish-reglobbe,項目名稱:Auction,代碼行數:31,代碼來源:Dealers.php

示例3: update

 /**
  * 更新數據
  * @param bool $runValidation
  * @param null $attributeNames
  * @return bool|int
  * @throws \Exception
  */
 public function update($runValidation = true, $attributeNames = null)
 {
     $result = parent::update($runValidation, $attributeNames);
     if ($result) {
         if (self::enableCache()) {
             Yii::trace('delete cache:' . self::getCacheKey($this->getAttribute(static::$pk)), __METHOD__);
             Yii::$app->cache->delete(self::getCacheKey($this->getAttribute(static::$pk)));
             Yii::$app->cache->delete(self::getCacheKey($this->getAttribute(static::$pk), false));
         }
     }
     return $result;
 }
開發者ID:heartshare,項目名稱:yii2-liuxy-extension,代碼行數:19,代碼來源:ActiveRecord.php

示例4: softDelete

 /**
  * prefering soft-delete instead of deleting permanently
  * adding delete time & blamable user
  *
  * @return boolean
  */
 public function softDelete()
 {
     /* simpan waktu delete (soft-delete) */
     if ($this->isSoftDeleteEnabled) {
         $this->setAttribute('deleted_at', time());
         if ($this->hasAttribute('deletedBy_id')) {
             $this->setAttribute('deletedBy_id', Yii::$app->user->getId());
         }
         return parent::update(FALSE);
     }
     /* delete record dr database (hard-delete) */
     return $this->hardDelete();
 }
開發者ID:AlvaCorp,項目名稱:yii2-boilerplate,代碼行數:19,代碼來源:Model.php

示例5: update

 public function update($runValidation = true, $attributeNames = NULL)
 {
     if (!empty($this->password)) {
         $this->password_hash = Yii::$app->security->generatePasswordHash($this->password);
     }
     $assignment = \backend\models\AuthAssignment::findOne(['user_id' => $this->id]);
     if ($assignment != null) {
         $assignment->item_name = $this->auth_item;
         if (!$assignment->update()) {
             print_r($assignment->getErrors());
             exit;
         }
     } else {
         $this->save_assignment($this->id);
     }
     $this->status = $this->status == 1 ? 10 : 0;
     parent::update();
     return true;
 }
開發者ID:mahmoodkhoeini,項目名稱:yii2cms,代碼行數:19,代碼來源:User.php

示例6: update

 /**
  * (non-PHPdoc)
  * @see \yii\db\ActiveRecord::update()
  */
 public function update($runValidation = true, $attributeNames = null, $hasParentModel = false, $fromUpdateAll = false)
 {
     if ($this->getReadOnly() && !$hasParentModel) {
         // return failure if we are at the top of the tree and should not be asking to supdateAll
         // not allowed to amend or delete
         $message = 'Attempting to update on ' . Tools::getClassName($this) . ' readOnly model';
         //$this->addActionError($message);
         throw new Exception($message);
     } elseif ($this->getReadOnly() && $hasParentModel) {
         $message = 'Skipping update on ' . Tools::getClassName($this) . ' readOnly model';
         $this->addActionWarning($message);
         return true;
     } else {
         try {
             $ok = parent::update($runValidation, $attributeNames);
         } catch (\Exception $e) {
             $ok = false;
             $this->addActionError($e->getMessage(), $e->getCode());
         }
         return $ok;
     }
 }
開發者ID:fangface,項目名稱:yii2-concord,代碼行數:26,代碼來源:ActiveRecord.php


注:本文中的yii\db\ActiveRecord::update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。