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; }
posted @ 2017-05-16 16:44  calmly  阅读(473)  评论(0编辑  收藏  举报