这是artilce_info
表
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('title');
$table->integer('read_num');
$table->timestamps();
这是插入的代码
DB::beginTransaction();
try {
$artInfoId = DB::table('article_info')->insertGetId([
'title' => $title,
'user_id' => $userId,
'read_num' => 0,
]);
DB::table('article')->insert([
'art_info_id' => $artInfoId,
'content' => $body,
]);
DB::commit();
return redirect()->route('blog.index');
} catch(Exception $exception) {
DB::rollBack();
return back()->withErrors($exception->getMessage())->withInput();
}
插入一条数据和,数据库中created_at
和updated_at
字段为0000-00-00 00:00:00
。
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…