I have a function that inserts a load of values into a database. Not a problem but I have a condition that changes the mysql statement. The problem is is the way wordpress constructs the statement, below is what I've tried...
public function sqlInsertTicket($event, $customer, $ticket){
$reference = 0;
if ($customer['gender']=="F"){
$table = "f_ti";
$sql ='"ft_num"=>"'.$ticket['number'].'","booking_id"=>"'.$ticket['booking'].'"';
}
if ($customer['gender']=="M"){
$table = "m_ti";
$sql ='"ticket_num"=>"'.$ticket['number'].'","mbooking_id"=>"'.$ticket['booking'].'"';
}
$this->edb->insert(
$table,
array(
$sql,
'event_id' => $event['id'],
'original_ev' => $event['id'],
'age' => $customer['age']
)
);
return $this->edb->insert_id;
}
I've removed a lot of the values but you can see what I'm trying to do. The $sql variable is what changes. I could write the whole thing out twice but, I've got lots of these to do and it would save a lot of time in the long run.
Wordpress is basically treating the $sql as 0 for the column name and doing crazy things with the values.
Thanks Joe