Basically one row from Excel will insert/update 4 rows in MySQL.
May use PhpSpreadsheet for an easy iteration of Excel file.
The logic in in pseudo-php-code
will be something like:
For inserts only:
// Statement prepare
$DB = new PDO('mysql:host='.$host.';dbname='.$base., $user, $pass);
$ST = $DB->prepare('insert into table(field1, fiel2, ..) values (:field1, :field2, ..)');
// Excel iteration
while ($Row = $Excel->NextRow()) {
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['D']]);
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['E']]);
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['F']]);
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['G']]);
}
For synchronization:
// Statement prepare
$DB = new PDO('mysql:host='.$host.';dbname='.$base., $user, $pass);
// Update statement
$ST = $DB->prepare('update table set field2 = :field2 where field1 = :field2 and ..)');
// Excel iteration
while ($Row = $Excel->NextRow()) {
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['D']]);
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['E']]);
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['F']]);
$ST->execute(['field1' => $Row['A'], .. 'field2' => $Row['G']]);
}
Hope you got the idea.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…