如何在symfony 1.4中插入多个记录?

时间:2014-09-10 09:12:47

标签: php mysql symfony-1.4 doctrine-1.2

我尝试在一个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万条记录。

1 个答案:

答案 0 :(得分:0)

解决方案是使用清晰的SQL,而不是Doctrine DQL或类似的东西。 http://oldforum.symfony-project.org/index.php/m/98628/#msg_num_5