我尝试在一个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();
两者都不起作用:(试图保存近20000条记录。
最佳答案
解决方案是使用清晰的SQL,而不是Doctrine DQL或类似的东西。
http://oldforum.symfony-project.org/index.php/m/98628/#msg_num_5
关于php - 如何在symfony 1.4中插入多个记录?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25761565/