tp5框架的软删除
首先在模型中我们要引入
use traits\Model\SoftDelete;
在类中引入
use SoftDelete;
模型层的代码参考:在这里我们需要注意一个问题,(添加的$delete_time的类型不能是时间戳类型 我们需要手动将其设置成int类型)
<?php
namespace app\admin\model;
use think\Model;
use traits\Model\SoftDelete;
class users extends Model
{
use SoftDelete;
protected $table='users';
protected $deleteTime='delete_time';
public static function del($id)
{
return self::destroy($id); // TODO: Change the autogenerated stub
}
}
本文来自博客园,作者:鱼祖,转载请注明原文链接:https://www.cnblogs.com/fishn/p/15178847.html

浙公网安备 33010602011771号