Delete multiple rows from DB with Vue Js and CakePHP

26 Views Asked by At

I'm trying to delete a multiple rows with the same value in MySQL Server with CakePHP 2.5 and Vue Js, but continuously got an error in request. I have next controller:

public function delete_rows($constructionNum) {
        $this->autoRender = false;
    
        if ($this->request->is('get')) {
            throw new MethodNotAllowedException();
        }
    
        $this->DpInv->deleteAll(array('Construction' => $constructionNum));
    
        $this->setResSuccess();
    }

and next function in Vue Js:

 check: function () {
        var self = this; // Store reference to the Vue instance
        this.showModal = false;
        document.body.style.overflow = "auto";

        var url = PROJECT_PATH + "/api_out/delete_rows/" + app.constructionNum;
        var req = xhrRequest(request.delete(url));

        req.field("constructionNum", app.constructionNum);

        this.isUploading = true;

        req.end(function (err, res) {
          if (err) {
            alert("got an error here");
            return;
          }
          var body = res.body;
          if (body.result !== "success") {
            return;
          }

          alert("should be deleted");
        });

        checkModal.show();
      },

app.constructionNum is received from app Vue Js instance and has a value "0024-0000". However every time I call, req.end I end up with internal error. I tried without passing a value to Controller's function, but still got no results. I've checked API status and it was 500. Is there any way to delete rows from DB?

0

There are 0 best solutions below