//修改
    public function actionUpdateNews(){
        //接收前端json数据
        $data = file_get_contents('php://input');
        //解析json转成数组
        $last_data = json_decode($data,true);
        //取值
        $id = $last_data['id'];

        unset($last_data['id']);

        $model = News::findOne($id);
        foreach ($last_data as $k => $v){
            $model->$k = $v;
            $model->save(false);
        }

        return ['code'=>200,'msg'=>'成功','data'=>null];
    }

 

相关文章:

  • 2022-12-23
  • 2021-12-16
  • 2022-01-08
  • 2021-07-16
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案