gpt4 book ai didi

php - SQLSTATE[42S22] : Column not found: 1054 Unknown column laravel 5. 1

转载 作者:行者123 更新时间:2023-11-29 11:10:17 29 4
gpt4 key购买 nike

我有这个 QueryException

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into `comentarios` (`NombreUsuario`, `CorreoUsuario`, `TelefonoUsuario`, `Asunto`, `Mensaje`, `FecComentario`, `updated_at`, `created_at`) values (Andres, poc@dw.xom, 124422432, Andres es genial, vffgdf, 2016-11-20 03:34:45, 2016-11-20 03:44:18, 2016-11-20 03:44:18))

这是我的 Laravel 5.1 的 sql

public function store(Request $request)
{

\JuanSapo\ContadorT::create([
'NombreUsuario' => $request['nombres'],
'CorreoUsuario' => $request['email'],
'TelefonoUsuario' => $request['numContacto'],
'Asunto' => $request['asunto'],
'Mensaje' => $request['mensaje'],
'FecComentario' => $request['fecha']

]);

return view('contacto');
}

我可以看到,最后我还有两个日期,这看起来是我的 sql 错误,

这是我的 auth.php

<?php

return [

'driver' => 'eloquent',

'model' => JuanSapo\User::class,
'model' => JuanSapo\ContadorT::class,

'table' => 'users',
'table' => 'comentarios',

'password' => [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],

];

这是我的 User.php

<?php

namespace JuanSapo;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;

protected $table = 'users';

protected $fillable = ['name', 'email', 'password'];

protected $hidden = ['password', 'remember_token'];
}

这是我的 contadotT.php

<?php

namespace JuanSapo;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class ContadorT extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;


protected $table = 'comentarios';

protected $fillable = ['NombreUsuario', 'CorreoUsuario', 'TelefonoUsuario','Asunto','Mensaje','FecComentario'];

protected $hidden = ['contador'];
}

最佳答案

您必须在 ContadorT 模型类中添加 public $timestamps = false;,这样 Laravel 就不会添加 clated_atupdate_at 查询中的字段

关于php - SQLSTATE[42S22] : Column not found: 1054 Unknown column laravel 5. 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40700526/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com