I ended up using a combination of my own solution and Tommy B's. I wrote two PHP scripts. Each time, the PHP script would parse relevant data from a csv file, storing the information in an array, looping through the array and then using code that the civicrm API generated for doing participant and contribution data inserts.
define ('SITEROOT', '/home/****/public_html');
define('CIVIROOT', SITEROOT.'/administrator/components/com_civicrm/civicrm');
require_once CIVIROOT.'/civicrm.config.php';
require_once CIVIROOT.'/CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
echo 'CiviCRM has been successfully initialized.<br/><br/>';
require_once 'CRM/Utils/Request.php';
//is dryrun unless ?dryrun=0
$nA = CRM_Core_DAO::$_nullArray;
$dryrun = CRM_Utils_Request::retrieve('dryrun', 'Positive', $nA, FALSE, 1, 'REQUEST');
echo 'dryrun: '.($dryrun?'TRUE':'FALSE').'<br/><br/>';
$mysqli = new mysqli("localhost", "*******", "*****", "*******");
$csvFile = file('eventsFull.csv');
$data = [];
foreach ($csvFile as $line) {
$data[] = str_getcsv($line);
}
foreach ($data as $row) {
$eventID = $row[93];
$statusID = $row[19];
.......etc
//// This is from the API below /////////
$result = civicrm_api3('Participant', 'create', [
'event_id' => $eventID,
'contact_id' => $userID,
'status_id' => $statusID,
'role_id' => $roleID,
'register_date' => $registrationDate,
'source' => $source,
'fee_level' => $feeLevel,
'fee_amount' => $price,
'fee_currency' => $currency,
'discount_amount' => $discount,
'custom_35' => $dietNeeds,
'is_pay_later' => $isPayLater,
]);
$i++;
}
There was some more to the code, but that was the general idea. I had two other imports, three in total. One for $result = civicrm_api3('Contribution', 'create',
One for $result = civicrm_api3('Participant', 'create', [
and one for $result3 = civicrm_api3('ParticipantPayment', 'create', [