我的表customtables
包含以下列
----------------------------------------------------------------------------------------
My-Id(int-primarykey-autoincrement) | My-column-Name(string) | My-Created-By(int) |
My-Created-Time(timestamp) | MY-Updated-By(int) | My-updated-Time(timestamp)
----------------------------------------------------------------------------------------
我将尝试使用此代码插入数据
$mymodelclass = new mymodelclass;
$mymodelclass->My-column-Name = Input::get('column-name');
--------------------------
--------------------------
$mymodelclass->My-Created-By = Auth::user()->Login_Id;
$mymodelclass->My-Created-Time = DB::raw('CURRENT_TIMESTAMP');
$mymodelclass->save();
和mymodelclass
就是这个
class Asset extends Eloquent {
protected $fillable = array('My-column-Name,My-Created-By,...,My-Created-Time,
MY-Updated-By,My-updated-Time');
protected $primaryKey = "My-Id";
protected $table = 'customtables';
}
但是我收到了这个错误
Column not found: 1054 Unknown column 'updated_at' in 'field list'
(SQL: insert into `customtables`
(`My-column-Name`,..., `My-Created-Time`,`updated_at`, `created_at`)
values
(Qwerty,..., CURRENT_TIMESTAMP, 2014-02-08 14:53:53, 2014-02-08 14:53:53))
我没有名为created_at
和updated_at
的列,而且我对该列名称并不感兴趣。我可以做些什么来保存数据。
答案 0 :(得分:3)
您需要关闭Laravel的自动时间戳。
public timestamps = false;
把它放在模型中。