Answers for "mongodb uploading csv php"

PHP
0

mongodb uploading csv php

<?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";
        }
       $users[] =$data;
       var_dump($users);
       $collection->batchInsert($users);
    }
?>
Posted by: Guest on February-16-2020

Browse Popular Code Answers by Language