PDO::ERRMODE_EXCEPTION] ); $batch = 500; // ============================================================ // m_patient // ============================================================ echo "=== Migrasi m_patient ===\n"; $total = 0; $stmt_upd = $pdo->prepare("UPDATE m_patient SET M_PatientName_enc = ?, M_PatientName_bidx = ?, M_PatientHP_enc = ?, M_PatientHP_bidx = ?, M_PatientDOB_enc = ?, M_PatientDOB_bidx = ?, M_PatientEmail_enc = ?, M_PatientPhone_enc = ?, M_PatientPOB_enc = ?, M_PatientIDNumber_enc = ?, M_PatientNIK_enc = ?, M_PatientNIK_bidx = ?, M_PatientNIP_enc = ? WHERE M_PatientID = ?"); while (true) { $rows = $pdo->query( "SELECT M_PatientID, M_PatientName, M_PatientHP, M_PatientDOB, M_PatientEmail, M_PatientPhone, M_PatientPOB, M_PatientIDNumber, M_PatientNIK, M_PatientNIP FROM m_patient WHERE M_PatientName_enc IS NULL LIMIT $batch" )->fetchAll(PDO::FETCH_ASSOC); if (empty($rows)) break; foreach ($rows as $row) { $dob_str = $row['M_PatientDOB'] ? date('d-m-Y', strtotime($row['M_PatientDOB'])) : ''; $stmt_upd->execute([ $enc->encrypt($row['M_PatientName']), $enc->search_bidx($row['M_PatientName']), $enc->encrypt($row['M_PatientHP']), $enc->search_bidx($row['M_PatientHP']), $enc->encrypt($dob_str), $enc->search_bidx($dob_str), $enc->encrypt($row['M_PatientEmail']), $enc->encrypt($row['M_PatientPhone']), $enc->encrypt($row['M_PatientPOB']), $enc->encrypt($row['M_PatientIDNumber']), $enc->encrypt($row['M_PatientNIK']), $enc->search_bidx($row['M_PatientNIK']), $enc->encrypt($row['M_PatientNIP']), $row['M_PatientID'], ]); $total++; } echo " {$total} rows...\n"; } echo "m_patient selesai: {$total} rows\n\n"; // ============================================================ // m_patientaddress // ============================================================ echo "=== Migrasi m_patientaddress ===\n"; $total = 0; $stmt_addr = $pdo->prepare("UPDATE m_patientaddress SET M_PatientAddressDescription_enc = ?, M_PatientAddressEmail_enc = ?, M_PatientAddressPhone_enc = ? WHERE M_PatientAddressID = ?"); while (true) { $rows = $pdo->query( "SELECT M_PatientAddressID, M_PatientAddressDescription, M_PatientAddressEmail, M_PatientAddressPhone FROM m_patientaddress WHERE M_PatientAddressDescription_enc IS NULL LIMIT $batch" )->fetchAll(PDO::FETCH_ASSOC); if (empty($rows)) break; foreach ($rows as $row) { $stmt_addr->execute([ $enc->encrypt($row['M_PatientAddressDescription']), $enc->encrypt($row['M_PatientAddressEmail']), $enc->encrypt($row['M_PatientAddressPhone']), $row['M_PatientAddressID'], ]); $total++; } echo " {$total} rows...\n"; } echo "m_patientaddress selesai: {$total} rows\n\n"; echo "=== Migrasi patient PII selesai ===\n";