database - 使用 Laravel Eloquent 在表中插入关联数组

标签 database laravel-4 insert eloquent

如何使用 Laravel Eloquent 插入关联数组

我有这个数组

$data =  array (
  0 => 
    array (
      'first_id' => string '52763718329' 
      'second_id' => string '222122'
  ),
  1 => 
    array(
      'first_id' => string '527628573' (length=9)
      'second_id' => string '22210' (length=5)
   )
);

$model = new MyModel;
//$model->$data how do I pus data array?
$model->save();

最佳答案

$data = $data->ToArray();

DB::table('mytable')->insert($data);

关于database - 使用 Laravel Eloquent 在表中插入关联数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25951684/

相关文章:

mysql - 删除 MySQL 整个数据库。 MySQL 数据库中未显示数据库

php - Laravel 聊天中的长轮询 : Why is the div not updating itself?

javascript - 从 Laravel 数据库中实时提取数据

mysql - 在 Laravel 中使用 DataTables 时出现无效参数编号错误

java - Android 批量插入或忽略 JSONArray

php - MySQLI Update set +1 正确的形式和符号

sql-server - 两个 (SELECT TOP 1 +1 ) 语句和两个 INSERTS 同时

PHP MySQL数据库设计

javascript - onclick 切换插入的元素

mysql - nodejs中事件驱动事务中的数据库插入/更新