Must use update first then where, the update data must contain the primary key of the table otherwise can not updated automatically.
if(PositionModel::update($data)->where(‘id’, $applied_id)){
return [‘code’=>0,‘msg’=>‘Status updated.’];
}else{
return [‘code’=>1,‘msg’=>‘No status updated!’];
}
class Position extends Model
{
protected $pk = ‘id’;
protected $table = ‘position’;
protected $autoWriteTimestamp = true;
protected $createTime = ‘create_time’;
protected $updateTime = ‘update_time’;
protected $dateFormat = ‘Y-m-d H:i’;
}
how to use thinkPHP model to update update_time in DB automatically
最新推荐文章于 2024-04-18 11:47:31 发布