简体   繁体   中英

How to insert multiple records in symfony 1.4?

I try to insert 1 000 - 30 000 records in one http request. And I cannot manage with this.

My codes:

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();

Both don't work :( Trying to save almost 20 000 records.

The solution is to use clear SQL, not Doctrine DQL or something like that. http://oldforum.symfony-project.org/index.php/m/98628/#msg_num_5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM