param() obtains the entire object, and there are many things in it that are not fields in your data table. You must first print out the data in $data and take a closer look at your code, such as saving the user name. The $data['username'] you submitted is not what you want. You have to find the parameters you need first and then save them.
可以看看这个 public function add() { if ($this->request->isAjax()) { $data = [ 'icon' => $this->request->post('icon'), 'title' => $this->request->post('title'), 'orderby' => $this->request->post('orderby') ]; $this->service->addShopCate($data); $this->response(); } else { return $this->fetch(); } }param() obtains the entire object, and there are many things in it that are not fields in your data table. You must first print out the data in $data and take a closer look at your code, such as saving the user name. The $data['username'] you submitted is not what you want. You have to find the parameters you need first and then save them.
I don’t understand what your problem is. Isn’t the code for inserting into the database already written in your program?