【问题标题】:exclude entity variable from PUT request从 PUT 请求中排除实体变量
【发布时间】:2019-11-12 03:14:37
【问题描述】:

我通过 put 请求将实体发送到数据库,但其中一个变量给我带来了麻烦。我想知道是否有办法从请求中排除单个变量。

我正在使用 axios 进行数据库连接。

这是被发送的实体。

        $this->id = 0;
        $this->user = '';
        $this->type = '';
        $this->status = null;
        $this->signatureList = new ArrayCollection();

        //this is the array i want to exclude
        $this->amendmentList = new ArrayCollection();
        $this->draft = true;
        $this->archived = false;
        $this->canceled = false;
        $this->finished = false;
        $this->signed = false;
        $this->subject = null;
        $this->content = '';
        $this->createdAt = new \DateTime();
        parent::__construct();

这是放置请求。

//it gets the entity through the id and sends it whole 
update: (id, data) => {
        window.httpMessage = { show: true, success: `Documento <b>#${id}</b> Atualizado`, error: "Documento <b>não Atualizado</b>" }
        return http.put(`/eletronic-documents/${id}`, data).then(res => res.data)
    }

【问题讨论】:

  • stackoverflow.com/a/41959141/4248328。将它们分配给一个变量,然后使用unset() 取消设置您要删除的任何实体
  • 如果您显示您正在使用的代码将会很有帮助。 “从请求中排除单个变量”的明显答案是简单地不包含它。
  • 在客户端,您可以使用 delete 运算符从 axios 请求中删除实体。没有代码,我们无法提供进一步的帮助。
  • 你可以使用array_filter()

标签: javascript php mysql axios


【解决方案1】:

正如用户 steadweb 所建议的,在客户端删除就可以了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    • 1970-01-01
    • 2014-09-22
    相关资源
    最近更新 更多