You are creating a string
….
$sql=""ft_num"=>"".$ticket['number'].'","booking_id"=>"'.$ticket['booking'].'"';
… but expecting it to operate as an array…
array(
$sql,
'event_id' => $event['id'],
This has nothing to do with how WordPress does anything. This is pure PHP. You have literally created this:
array(
[] => "ft_num"=>"'.$ticket['number'].'","booking_id"=>"'.$ticket['booking'].'",
'event_id' => $event['id'],
You need to build the array dynamically.
$dynargs = array(
'event_id' => $event['id'],
'original_ev' => $event['id'],
'age' => $customer['age']
)
if ($customer['gender']=="F"){
$table = "f_ti";
$dynargs['ft_num'] = $ticket['number'];
$dynargs['booking_id'] = $ticket['booking'];
} elseif ($customer['gender']=="M"){
$table = "m_ti";
$dynargs['ticket_num'] = $ticket['number'];
$dynargs['mbooking_id'] = $ticket['booking'];
}
$this->edb->insert(
$table,
$dynargs
);
return $this->edb->insert_id;
I wrote that on the spot. It may be buggy but that is the idea.