2014-09-10 59 views
0

我嘗試在一個http請求中插入1 000 - 30 000條記錄。而我無法處理這一點。如何在symfony 1.4中插入多個記錄?

我的代碼:

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

而不是更新您的問題以包括答案,您應該更好地發佈答案並接受它。這是Stackoverflow的工作方式來定義一個問題解決。 – j0k 2014-11-25 08:42:11

回答