Insert sql query in loop a good practice or bad?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a list of users which needs to be iterated using a foreach loop and inserted in to a table for every new row in db table. $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 ,