我尝试在一个http请求中插入1 000 - 30 000条记录。我无法解决这个问题。
我的代码:
foreach ($recipients as $recipient) {
$notificationHubAction = new NotificationHubAction();
$notificationHubAction->setNotificationId($popup->getId());
$notificationHubAction->setUserId($recipient['id']);
$notificationHubAction->save();
$notificationHubAction->free();
}
$notificationHubActions = new Doctrine_Collection('NotificationHubAction');
foreach ($recipients as $recipient) {
$notificationHubAction = new NotificationHubAction();
$notificationHubAction->setNotificationId($popup->getId());
$notificationHubAction->setUserId($recipient['id']);
$notificationHubActions->add($notificationHubAction);
}
$notificationHubActions->save();
两者都不能工作:(试图保存近2万条记录。
答案 0 :(得分:0)
解决方案是使用清晰的SQL,而不是Doctrine DQL或类似的东西。 http://oldforum.symfony-project.org/index.php/m/98628/#msg_num_5