代码如下:
$totalCount = 100;
$count = 0;
$data = [];
while($count < $totalCount){
$data[] = [‘名字’.$count,’地址’.$count];
$count++;
}
Yii::$app->db->createCommand()->batchInsert(‘`user`‘,[‘name’,’address’],$data)->execute();
代码如下:
$totalCount = 100;
$count = 0;
$data = [];
while($count < $totalCount){
$data[] = [‘名字’.$count,’地址’.$count];
$count++;
}
Yii::$app->db->createCommand()->batchInsert(‘`user`‘,[‘name’,’address’],$data)->execute();