$sql = "INSERT into $table ($fields) values ($values)";
An INSERT ... VALUES statement inserts only one record per execution. You're collecting your data from a structured file using nested loops, so I doubt that it can be modeled very well with a single database record.
For efficiency you can prepare an INSERT statement once, using question marks as placeholders for the individual values, then loop through all the records. On each pass through the loop, bind a new set of values to the placeholders, then call execute() on the statement handle.
In fact you need multiple INSERT statements, one for each destination table.
You may wish to prepare all your INSERT statements before you begin reading the data, then call bind and execute at all the places you have marked with # push
In reply to Re: Inserting Multiple Records in DB.
by Narveson
in thread Inserting Multiple Records in DB.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |