Heim  >  Fragen und Antworten  >  Hauptteil

So fügen Sie $request->param()-Daten in die Datenbank ein

捕获.PNG

LL1926 Tage vor1655

Antworte allen(4)Ich werde antworten

  • 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();
        }
    }

    Antwort
    0
  • 锅锅不黑

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

    param()获取的是整个对象,里面有很多东西不是你数据表字段的,你得先打印出$data里面得数据仔细看看,看你代码,比如保存用户名。你提交过来的$data['username'],这个是不是你想要的。你得先把你需要的参数找出来再保存。

    Antwort
    0
  • 殘留の回憶

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

    不明白你的问题是什么,你的程序里不是已经写了插入数据库的代码了

    Antwort
    0
  • L

    但是直接用$data插入不了总是报错,类型不正确

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