我使用下面的语句在表格中输入数据'歌曲'在命令提示符下使用php artisan tinker,但它显示PHP Parse error: Syntax error, unexpected T_OBJECT_OPERATOR, expecting ']' on line 1
。
DB::table('songs')->insert(['title'->'Closer','artist'->'chainsmokers','created_at'->new DateTime,'updated_at'->new DateTime ]);
答案 0 :(得分:2)
使用=>
代替->
DB::table('songs')->insert([
'title' => 'Closer',
'artist' => 'chainsmokers',
'created_at' => new DateTime,
'updated_at' => new DateTime,
]);