cornernote/yii2-softdelete
Composer 安装命令:
composer require cornernote/yii2-softdelete
包简介
Soft delete behavior for Yii2.
关键字:
README 文档
README
Soft delete behavior for Yii2.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require cornernote/yii2-softdelete "*"
or add
"cornernote/yii2-softdelete": "*"
to the require section of your composer.json file.
Usage
In your ActiveRecord class:
public function behaviors() { return [ \cornernote\softdelete\SoftDeleteBehavior::className(), // or [ 'class' => \cornernote\softdelete\SoftDeleteBehavior::className(), 'attribute' => 'deleted_time', 'value' => new \yii\db\Expression('NOW()'), // for sqlite use - new \yii\db\Expression("date('now')") ], ]; }
then you can use explicitly $model->softDelete(), $model->hardDelete()
and $model->unDelete() (for softly deleted models). Each of these methods return
boolean result. Also $model->softDelete() calls indirectly from $model->delete(),
which always returns false.
In your ActiveQuery class:
public function behaviors() { return [ \cornernote\softdelete\SoftDeleteQueryBehavior::className(), // or [ 'class' => \cornernote\softdelete\SoftDeleteQueryBehavior::className(), 'attribute' => 'deleted_time', ], ]; }
统计信息
- 总下载量: 15.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-06-02