Laravel is recently used. If you want to insert nearly a thousand pieces of data in batches, you can insert data in batches by Directly Writing SQL statements. In addition, the framework ORMEloquent provides a Create method: {code...}. This method can easily insert data, but cannot insert data in batches. Based on performance considerations, I do not want to... I recently used Laravel.
If you want to insert nearly a thousand pieces of data in batches, you can insert data in batches by Directly Writing SQL statements.
In addition, the framework ORM Eloquent provides a Create method:
/** * Save a new model and return the instance. * * @param array $attributes * @return \Illuminate\Database\Eloquent\Model|static */ public static function create(array $attributes) { $model = new static($attributes); $model->save(); return $model; }
This method can easily insert data, but cannot insert data in batches.
Based on performance considerations, I do not want to write SQL. Does Eloquent have a method for this situation?
Reply content:
Laravel is recently used.
If you want to insert nearly a thousand pieces of data in batches, you can insert data in batches by Directly Writing SQL statements.
In addition, the framework ORM Eloquent provides a Create method:
/** * Save a new model and return the instance. * * @param array $attributes * @return \Illuminate\Database\Eloquent\Model|static */ public static function create(array $attributes) { $model = new static($attributes); $model->save(); return $model; }
This method can easily insert data, but cannot insert data in batches.
Based on performance considerations, I do not want to write SQL. Does Eloquent have a method for this situation?
DB::table('users')->insert(array( array('email' => 'taylor@example.com', 'votes' => 0), array('email' => 'dayle@example.com', 'votes' => 0),));
Details