【发布时间】:2017-06-21 13:58:17
【问题描述】:
我已使用以下方法从 db 中检索了一些数据:
$filtered = DB::table('tmp_table')->distinct()->select('type','description','note')->get();
我想在另一个表中插入我检索到的内容,例如:
DB::table('tmp_other')->insert($filtered);
但我收到了错误:
Type error: Argument 1 passed to Illuminate\Database\Query\Builder::insert() must be of the type array, object given
哪种方法最好?
【问题讨论】:
-
DB::table('tmp_other')->insert($filtered->toArray());应该可以工作。 -
@StefanoMaglione 好吧...你明白了吗,错误信息中写了什么?
-
Eloquent 标签在这里不适用吗?