PHP - Insert Into mysql multiple rows best approach
Ok, so let`s presume I have 3 sql tables and a text file. Text file is in
CSV format. File structure - imagine a array for each line. Value 0
timestamp; 1,4,7,10 values for tab 1; 2,5,8,11 values for tab 2; 3,6,9,12
values for tab 3. What is the best approach for inserting data after
processing into db? Solution 1. foreach line read "insert into tab ... ;"
which I currently use and it takes a lot of time. Solution 2. foreach line
read push the sql statement into an array, and when I have all the lines
processed make a string like "Insert into tab...; insert into tab...;
insert into tab...;" and execute the query. File has aprox. 4000 lines and
I have 7 values for each table.
No comments:
Post a Comment