您正在创建string
....
$sql =\'"ft_num"=>"\'.$ticket[\'number\'].\'","booking_id"=>"\'.$ticket[\'booking\'].\'"\';
。。。但希望它作为一个数组运行。。。
array(
$sql,
\'event_id\' => $event[\'id\'],
这与WordPress的工作方式无关。这是纯PHP。您确实创建了以下内容:
array(
[] => "ft_num"=>"\'.$ticket[\'number\'].\'","booking_id"=>"\'.$ticket[\'booking\'].\'",
\'event_id\' => $event[\'id\'],
您需要动态构建阵列。
$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;
那是我当场写的。这可能是马车,但这就是想法。