I got a problem when trying to import more than 30,000 data to database from excel file. Each data needs to be validated first before inserted to database. I use AR only for validating data, then switch to query builder when inserting them.
$query = Yii::app()->db->createCommand()->insert('material', array(
‘id'=>$material->id,
'category_id'=>$material->category_id,
'name'=>$material->name,
'image_type'=>$material->image_type,
'thickness'=>$material->thickness,
…..
'fuel'=>$material->fuel
));
The problem is application always runs out of memory:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes)
Additional details:
PHP version: 5.2.17 (the script works fine in PHP 5.3.1, but not in PHP 5.2 – due to this issue, IMO). Also, the web hosting I use doesn’t support PHP 5.3.
Memory limit: 128 MB (maximum memory allowed by my web hosting - cannot be increased again)
Yii version: 1.1.8
Is there any way to reduce memory usage and process them in PHP 5.2?