php - should I use ajax to import large csv file to mysql database? -


there large csv file need import mysql database
there ways bellow

1 , upload csv file using php

<?php $row = 1; $handle = fopen("test.csv","r"); while ($data = fgetcsv($handle, 1000, ",")) {     // record rows to database } fclose($handle); ?>  

this way easy ,but waiting long time

2, upload csv file using php
use ajax record each row of csv , output ajax feedback

<script type="text/javascript">     var row =0;     $.ajax({         url:"csv_to_db.php",    //record 1 row         type:"post",         data:{             row : row;         },         success:function(){             row++;         }     }); </script> 

this way can see active feedback ajax info ,and browser not die when method 1 wait long time
way excute fgetcsv function in "scv_to_db.php" every time, seems waiting cpu , memery


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -