首页 > 代码库 > yii2多数据入库

yii2多数据入库

第一种:
$model = new User(); foreach($data as $attributes) { $_model = clone $model; $_model->setAttributes($attributes); $_model->save(); }
第二种:
$model = new User(); foreach($data as $attributes) { $model->isNewRecord = true; $model->setAttributes($attributes); $model->save() && $model->id=0; }

yii2多数据入库