本文整理汇总了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);
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
}