找不到列:1054未知列laravel [英] Column not found: 1054 Unknown column laravel

查看:212
本文介绍了找不到列:1054未知列laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图用laravel制作表格,但在新版本中,他们删除了表格!但我可以让它运行

so i trying to make a form with laravel but other than in new version they removed form ! but i can get this running

所以这里是:

Route::post('/register', function()
{
    $user = new User;
    $user-> u_n = Input::get('u_n');
    $user->save();
    return View::make('thanks')->with('theEmail',$theEmail);
});

和我的刀片:

{{Form::open(array('url'=>'register'))}}

username : {{Form::label('u_n', 'E-Mail Address');}}
{{Form::text('u_n');}}
{{Form::submit('');}}

u_n是我的mysql数据库字段的名称 这是实际的错误:

u_n is name of my mysql data base field and this is the actual error :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into `users` (`u_n`, `updated_at`, `created_at`) values (sepehr, 2014-12-24 14:32:55, 2014-12-24 14:32:55))

推荐答案

之所以会发生这种情况,是因为Laravel假定您要为模型使用updated_atcreated_at时间戳.因此,它还假定它们存在于数据库中.您可以通过添加

This is happens because Laravel assumes you want to use the updated_at and created_at timestamps for your models. So it also assumes they exist in the database. You can either create the two columns or disable timestamps for your model by adding

public $timestamps = false;

Laravel文档

顺便说一句:如果您正在使用迁移,添加时间戳列很容易.

By the way: If you're using migrations, adding the timestamp columns is a breeze.

Schema::table('table_name', function(Blueprint $table){
    $table->timestamps();
}

这篇关于找不到列:1054未知列laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆