Hi all,
I’m using Yii 2.0.6 and got a “memory exhausted” error using the save() function in a forech loop.
My aim is to query some data from one table and insert/update it in some other table. Wihtout the save() function, the memory footprint remains the same. If I enable the save() line the memory footprint increases constanly. I’ve tried unset(), xy = NULL, __unset… nothing helped.
Any ideas?
Thank you in advance.
Chris
// fetch 100 products at a time and iterate them one by one
foreach (CatalogProducts::find()->select('Model')->distinct()->each(100) as $product) {
$web = WebshopProduct::findOne(['ArticleId' => $product->Model]);
if ($web == NULL) {
$web = new WebshopProduct();
}
$web->Column1 = 'Some data';
$web->Column2 = $product->Model;
$web->Variantencode = 'ABC';
$web->tsk_creationDate = '20150901 00:00:00';
$web->save();
// DEBUG
echo number_format(memory_get_usage()) . "\n";
}