Importing csv into mongodb using PHP code
问题 Im using MongoCollection::batchInsert() to insert csv data into mongodb, <?php $mongo = new Mongo("mongodb://192.168.1.7:27017"); $collection = $mongo->test->cartoons; $row = 1; $handle = fopen(dirname(Yii::app()->request->scriptFile).'/images/importcsv/upload.csv', "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; $users = array(); for ($c=0; $c < $num; $c++) { echo 'data--'.$data[$c] . "<br />\n";