mongodb uploading csv php

Solutions on MaxInterview for mongodb uploading csv php by the best coders in the world

showing results for - "mongodb uploading csv php"
Mariam
24 Jan 2019
1<?php
2
3$mongo = new Mongo("mongodb://192.168.1.7:27017");
4
5$collection = $mongo->test->cartoons;
6$row = 1;
7 $handle = fopen(dirname(Yii::app()->request->scriptFile).'/images/importcsv/upload.csv', "r");
8    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
9        $num = count($data);
10       echo "<p> $num fields in line $row: <br /></p>\n";
11       $row++;
12       $users = array();
13       for ($c=0; $c < $num; $c++) {
14            echo 'data--'.$data[$c] . "<br />\n";
15        }
16       $users[] =$data;
17       var_dump($users);
18       $collection->batchInsert($users);
19    }
20?>