我有一个用户列表,需要使用foreach循环迭代,并在每个新行插入到数据库表中。
$data['entity_classid'] = $classid;
$data['notification_context_id'] = $context_id;
$data['entity_id'] = $entity_id;
$data['notification_by'] = $userid;
$data['actionid'] = $actionid;
$data['is_read'] = 0;
$data['createdtime'] = time();
foreach($classassocusers as $users){
$data['notification_to'] = $users->userid;
$DB->insert_record('homework.comments',$data,false);
}
所以使用上述的插入查询是
- 好习惯还是坏习惯,
- 我是否应该在每个插入查询执行后加入任何延迟?
- 这样做的利弊是什么?
谢谢