这个函数的更好/更清晰的方法是在codeigniter控制器中的不同数据库表中创建多个记录:
private function newConcern($data) {
$this->load->model('customer_model', 'customer');
$this->load->model('complaints_dealers_model', 'dealer');
$this->load->model('vehicle_model', 'vehicle');
$this->load->model('complaints_vehicles_model', 'complaints_vehicles');
$this->load->model('complaints_emails_model', 'emails');
// create customer record
$this->customer->create($data['customer']);
// create concern record
$this->create($data['concern']);
// create dealer record
$this->dealer->create($data['dealer']);
// create vehicle record
$this->vehicle->create($data['vehicle']);
// create complaint vehicle record
$this->complaints_vehicles->create($data['complaint_vehicle']);
// check whether we have any email recipients
if (!empty($data['department']) || !empty($data['recipients'])) {
// process branch email
$this->emails->processBranchEmail($data, $concern->id);
}
return true;
}
尽管需要进行所有函数调用,但感觉这个函数还有太多功能。
有关更好方法的任何建议吗?