批改状态:未批改
老师批语:
<?php
public function select(){
StaffModel::select(function($query){
$query->where('age','>=',30)
->where('saraly','>',5000);
});
}
>2.软删除功能
1.首先在index/model/staff.php中添加软删除
<?php
namespace app\index\model;
use think\Model;
use think\model\concren\SoftDelete; //添加命名空间
class Staff exntends Model{
public fucntion softDelete(){
use SoftDelete; //等同把softDelete.php里面的代码加到这里
protected $defaultSoftDelete = 0; //设置删除字段的默认值
}
}
>2.在控制器中添加软删除方法
<?php
namespace app\index\controller;
use think\Contorller;
use think\model\concren\SoftDelete; //添加命名空间
public function softDelete(){
StaffModel::destroy(1);
}
>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号