意外的'=>' (T_DOUBLE_ARROW)

时间:2016-11-13 15:59:25

标签: php laravel

我收到以下错误,我无法找到问题的解决方案。可能有人能帮助我吗?

 DB::table('videos')->insert(
             ['video_id'        => $videos[$i]->title],
             ['url']            => $videos[$i]->url],
             ['default_thumb']  => $videos[$i]->default_thumb],
             ['thumb']          => $videos[$i]->thumb],
             ['publish_date']   => $videos[$i]->publish_date],
             ['tags']           => $videos[$i]->tags]
           );

错误消息是:

FatalErrorException in VideoController.php line 33:
syntax error, unexpected '=>' (T_DOUBLE_ARROW)

2 个答案:

答案 0 :(得分:0)

这是insert()方法的正确语法:

DB::table('videos')->insert([
         'video_id'       => $videos[$i]->title,
         'url'            => $videos[$i]->url,
         'default_thumb'  => $videos[$i]->default_thumb,
         'thumb'          => $videos[$i]->thumb,
         'publish_date'   => $videos[$i]->publish_date,
         'tags'           => $videos[$i]->tags
    ]);

答案 1 :(得分:0)

希望它能解决你的问题

DB::table('videos')->insert(
             ['video_id'        => $videos[$i]->title,
             'url'            => $videos[$i]->url,
             'default_thumb'  => $videos[$i]->default_thumb,
             'thumb'          => $videos[$i]->thumb,
             'publish_date'   => $videos[$i]->publish_date,
             'tags'           => $videos[$i]->tags]
           );