Laravel Jenssegers插入数组值

时间:2017-02-24 12:33:24

标签: mongodb laravel

我正在使用Laravel和mongodb(Jenssegers),我有如下的数组数据,

 $insert[] = ['sub_id'=>$loggedin,
              'userid' => $row->userid,
              'username' => $row->username,
              'email' => $row->email,
              'mobileno' => $row->mobileno,
              'manager_mail' => $row->manager_mail,
              'roleid' => $userrole->roleid];

我的插入查询是,

 $user->save($insert);

但它没有用,请建议任何解决方案?

2 个答案:

答案 0 :(得分:0)

您需要使用modelBuilder.Entity<GICSSector>().ToTable("GICSSectors"); create()方法:

insert()

或者:

User::create($insert);

或者:

User::insert($insert);

答案 1 :(得分:0)

Eloquent save方法接受2D数组。但是你提供了 $insert = ['sub_id'=>$loggedin, 'userid' => $row->userid, 'username' => $row->username, 'email' => $row->email, 'mobileno' => $row->mobileno, 'manager_mail' => $row->manager_mail, 'roleid' => $userrole->roleid]; $user->save($insert); 。请尝试以下代码:

{{1}}