I am having some trouble working with MongoDB in PHP at the moment.
I am pulling records of financial data from a CSV file almost a gig, I am looping through the file fine and outputting and parsing the array.
During the while loop I am also trying to insert the data in to MongoDB
// Increase timeout on php script
ini_set('max_execution_time', 600);
while (($data = fgetcsv($file, 0, ",")) !==FALSE) {
$parsedData['name'] = $data['0'];
$parsedData['email'] = $data['1'];
$parsedData['phone'] = $data['2'];
$parsedData['address'] = $data['3'];
$parsedData['gender'] = $data['4'];
$collection->insert($parsedData);
}
So the problem is that it inserts only one of the records or a few, I can't really say it seems quite random.
Any help here would be great.
Tests Completed
- Running the same function while testing with mysql returned successful.
- print_r($parsedData) displays desired values.
- Wrapping $collection->insert in an if statement returns true