第一种:
$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;
}