当前位置: 首页>>代码示例>>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;未经允许,请勿转载。