【问题标题】:LARAVEL : SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE valueLARAVEL:SQLSTATE [22007]:无效的日期时间格式:1292 截断不正确的 DOUBLE 值
【发布时间】:2020-12-05 09:34:51
【问题描述】:

我正在尝试创建一个路由来更新 mysql 表“orcamento”中的信息,但我收到了这个错误

在此处输入代码 SQLSTATE[22007]:日期时间格式无效:1292 截断不正确的 DOUBLE 值:'$orcamento->id'(SQL:更新 orcamento 设置 cliente = joao,vendedor = 卡洛斯,descricao = 2 观看视频,valor = 600,orcamento.updated_at = 2020-08-15 08:15:40 哪里 (id = $orcamento->id))

created_at 和 updated_at 由时间戳构建

enter code here    {
    Schema::create('orcamento', function (Blueprint $table) {
        $table->id();
        $table->text('vendedor');
        $table->text('cliente');
        $table->text('descricao');
        $table->double('valor',10,2);
        $table->timestamps();
    });
}


    

在路由更新中是这样的

public function update(OrcamentoRequest $request, $id)
    {
        $orcamentos = ModelsOrcamentoModel::where(['id'=>$id])->update([
            'cliente'=>$request->cliente,
            'vendedor'=>$request->vendedor,
            'descricao'=>$request->descricao,
            'valor'=>$request->valor
        ]);
        return redirect('cadastros');
    }

执行dd函数我得到了这个

'$orcamentos = ModelsOrcamentoModel::where(['id'=>$id])->dd($id,$request->valor);' 

"$orcamento->id" “600”

【问题讨论】:

  • 请在您的控制器中dd($id, $request->valor)。并通过编辑将输出添加到问题中。
  • "$orcamento->id" "600

标签: php mysql laravel


【解决方案1】:

我在表单中传递了错误的网址

 <form action="{{url('orcamentos/'.$orcamento->id)}}" name="formEdit" id="formEdit" method="post">

【讨论】:

    猜你喜欢
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多