📜  mongodb上传csv php代码示例

📅  最后修改于: 2022-03-11 14:54:14.475000             🧑  作者: Mango

代码示例1
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 "

$num fields in line $row:

\n"; $row++; $users = array(); for ($c=0; $c < $num; $c++) { echo 'data--'.$data[$c] . "
\n"; } $users[] =$data; var_dump($users); $collection->batchInsert($users); } ?>