기본적으로 Excel의 한 행은 MySQL에서 4 행을 삽입/업데이트합니다. PhpSpreadsheet을 사용하면 Excel 파일을 쉽게 반복 할 수 있습니다.
를 들어 삽입에만 :
// 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']]);
}
동기화 경우 :
// 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']]); }
당신이 아이디어를 가지고 희망 pseudo-php-code
에서의 논리는 무언가 같이 될 것입니다.
질문의 상태는 무엇입니까? 하나가 풀린다면 답을 받아 들여서 풀어야한다. 방법을 모른다면, 물어보십시오. 초록색이 될 때까지 대답 옆의 회색 체크 표시를 지우는 것입니다. –
이 코드는 어디에 있습니까? –