search

Home  >  Q&A  >  body text

How to insert $request->param() data into the database

捕获.PNG

LL2039 days ago1762

reply all(4)I'll reply

  • WJ

    WJ2020-05-27 14:03:11

    可以看看这个
    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();
        }
    }

    reply
    0
  • 锅锅不黑

    锅锅不黑2019-06-24 13:05:42

    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.

    reply
    0
  • 殘留の回憶

    殘留の回憶2019-06-16 21:44:59

    I don’t understand what your problem is. Isn’t the code for inserting into the database already written in your program?

    reply
    0
  • L

    However, I cannot insert directly using $data and always get an error because the type is incorrect.

    L · 2019-06-16 23:20:24
  • Cancelreply